Title: [Bug]: Markers with string-type integer values are converted to integers in cycler and matplotlibrc · Issue #29646 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Markers with string-type integer values are converted to integers in cycler and matplotlibrc · Issue #29646 · matplotlib/matplotlib
X Title: [Bug]: Markers with string-type integer values are converted to integers in cycler and matplotlibrc · Issue #29646 · matplotlib/matplotlib
Description: Bug summary When creating a cycler with a "marker" property value contains strings that could be converted to integers, they are always converted to integers, even if the string value is valid and the intended value. This is most obvious...
Open Graph Description: Bug summary When creating a cycler with a "marker" property value contains strings that could be converted to integers, they are always converted to integers, even if the string value is valid and ...
X Description: Bug summary When creating a cycler with a "marker" property value contains strings that could be converted to integers, they are always converted to integers, even if the string value is ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29646
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Markers with string-type integer values are converted to integers in cycler and matplotlibrc","articleBody":"### Bug summary\n\nWhen creating a cycler with a `\"marker\"` property value contains strings that _could_ be converted to integers, they are always converted to integers, even if the string value is valid and the intended value. This is most obvious with the list `[\"1\", \"2\"]`; which is distinctly different from `[1, 2]`. However, the latter is always used. **Edit (20.02.2025):** This is also the case for `\"lines.markers\"`, `\"boxplot.flierprops.marker\"`, `\"boxplot.meanprops.marker\"`, and `\"scatter.marker\"`.\n\nRelevant functions are `_validate_markers` ([here](https://github.com/matplotlib/matplotlib/blob/7ede0929dc39858a2801f8b6b2711db0d4fa5bfe/lib/matplotlib/rcsetup.py#L231)) and `_listify_validator` ([here](https://github.com/matplotlib/matplotlib/blob/7ede0929dc39858a2801f8b6b2711db0d4fa5bfe/lib/matplotlib/rcsetup.py#L97)). It seems like this issue was introduced by #27613, which solved a similar issue reported in #27596.\n\n### Code for reproduction\n**Edited 20.02.2025**\n```Python\nfrom matplotlib import cycler\nimport matplotlib.pyplot as plt\n\nmarkers = [\"1\", \"2\", \"o\", 4]\nprint(\"Cycler\")\ntest_cycler = cycler(\"marker\", markers)\nfor prop_dict in test_cycler:\n print(\n \"Marker {} with type {}.\".format(prop_dict[\"marker\"], type(prop_dict[\"marker\"]))\n )\nprint(\"lines.marker\")\nfor marker in markers:\n plt.rcParams[\"lines.marker\"] = marker\n print(\n \"Marker {} with type {}.\".format(\n plt.rcParams[\"lines.marker\"], type(plt.rcParams[\"lines.marker\"])\n )\n )\n```\n\n### Actual outcome\n\n```bash\n$ python main.py\nCycler\nMarker 1 with type \u003cclass 'int'\u003e.\nMarker 2 with type \u003cclass 'int'\u003e.\nMarker o with type \u003cclass 'str'\u003e.\nMarker 4 with type \u003cclass 'int'\u003e.\nlines.marker\nMarker 1 with type \u003cclass 'int'\u003e.\nMarker 2 with type \u003cclass 'int'\u003e.\nMarker o with type \u003cclass 'str'\u003e.\nMarker 4 with type \u003cclass 'int'\u003e.\n```\nwhich indicates that the string entries `\"1\"` and `\"2\"` are converted into integers. As the string `\"o\"` cannot be converted into an integer with `int(\"o\")`, it is used explicitly.\n\n### Expected outcome\n\n```bash\n$ python main.py\nCycler\nMarker 1 with type \u003cclass 'str'\u003e.\nMarker 2 with type \u003cclass 'str'\u003e.\nMarker o with type \u003cclass 'str'\u003e.\nMarker 4 with type \u003cclass 'int'\u003e.\nlines.marker\nMarker 1 with type \u003cclass 'str'\u003e.\nMarker 2 with type \u003cclass 'str'\u003e.\nMarker o with type \u003cclass 'str'\u003e.\nMarker 4 with type \u003cclass 'int'\u003e.\n```\nThis output would indicate that strings containing integers are parsed correctly.\n\n### Additional information\n\nThis bug was not present prior to #27613, but it did solve a similar bug.\n\nLooking at the code which causes this bug, `_validate_markers` ([here](https://github.com/matplotlib/matplotlib/blob/7ede0929dc39858a2801f8b6b2711db0d4fa5bfe/lib/matplotlib/rcsetup.py#L231)) and `_listify_validator` ([here](https://github.com/matplotlib/matplotlib/blob/7ede0929dc39858a2801f8b6b2711db0d4fa5bfe/lib/matplotlib/rcsetup.py#L97)), it's not clear to me why the validation is done this way. I.e., to validate types, values are explicitly converted to see if a `ValueError` is raised, instead of testing the type explicitly. Is this the intended method for validation?\n\n~~I have a draft solution, but I would like clarification on the intended validation mechanisms before I submit the code for review.~~ **Edit (20.02.2025):** Since finding that other RcParams entries are affected by this bug, my solution is no longer applicable.\n\n### Operating system\n\nFedora 41\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\nPython 3.12.9\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/conradhaupt","@type":"Person","name":"conradhaupt"},"datePublished":"2025-02-19T12:48:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/29646/matplotlib/issues/29646"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d082d33c-8048-107c-6097-eb43b122661c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 96E0:1EEE:1A82C36:2660B5A:6A4FB9FB |
| html-safe-nonce | a4e8d68e6ea95f65d55ac52c200d1806d1969f866b2ce263ef6a2c6e98294097 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NkUwOjFFRUU6MUE4MkMzNjoyNjYwQjVBOjZBNEZCOUZCIiwidmlzaXRvcl9pZCI6IjUxMzE2Mzk1ODg2MDc5OTg0NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 402fd68ccc7a0eec0a7f2233e70d67e6584bc3222f629bb33f28c994c9a94ac3 |
| hovercard-subject-tag | issue:2863239881 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/29646/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4616efef30f022d468f212a9da198685f24c5c3ecc4cf783e09564ead7548649/matplotlib/matplotlib/issues/29646 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4616efef30f022d468f212a9da198685f24c5c3ecc4cf783e09564ead7548649/matplotlib/matplotlib/issues/29646 |
| og:image:alt | Bug summary When creating a cycler with a "marker" property value contains strings that could be converted to integers, they are always converted to integers, even if the string value is valid and ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | conradhaupt |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width