Title: stackplot should not change Axes cycler · Issue #24024 · matplotlib/matplotlib · GitHub
Open Graph Title: stackplot should not change Axes cycler · Issue #24024 · matplotlib/matplotlib
X Title: stackplot should not change Axes cycler · Issue #24024 · matplotlib/matplotlib
Description: Usecase: I am producing various types of plots (some use rectangle collections, some regular plot-lines, some stacked plots) and wish to keep the colors synchronized across plot types for consistency and ease of comparison. While ax.plot...
Open Graph Description: Usecase: I am producing various types of plots (some use rectangle collections, some regular plot-lines, some stacked plots) and wish to keep the colors synchronized across plot types for consisten...
X Description: Usecase: I am producing various types of plots (some use rectangle collections, some regular plot-lines, some stacked plots) and wish to keep the colors synchronized across plot types for consisten...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/24024
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"stackplot should not change Axes cycler","articleBody":"Usecase: I am producing various types of plots (some use rectangle collections, some regular plot-lines, some stacked plots) and wish to keep the colors synchronized across plot types for consistency and ease of comparison.\r\n\r\nWhile `ax.plot()` and `matplotlib.patches.Rectangle()` support supplying a `CN` alias, stackplot throws a ValueError. For example:\r\n\r\n```\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.patches import Rectangle\r\nimport numpy\r\n\r\nmy_data = numpy.array([[1, 1, 1], [1, 2, 3], [4, 3, 2]])\r\nfig, ax = plt.subplots()\r\nax.plot([1, 3], [1, 3], color='C0')\r\nax.add_patch(Rectangle(xy=(1.5, 1.5), width=0.5, height=0.5, facecolor='C1'))\r\nax.stackplot([1, 2, 3], my_data, colors=['C2', 'C3', 'C4'])\r\nplt.show()\r\n```\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/__init__.py\", line 1412, in inner\r\n return func(ax, *map(sanitize_sequence, args), **kwargs)\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/stackplot.py\", line 73, in stackplot\r\n axes.set_prop_cycle(color=colors)\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/axes/_base.py\", line 1575, in set_prop_cycle\r\n prop_cycle = cycler(*args, **kwargs)\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py\", line 695, in cycler\r\n vals = validator(vals)\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py\", line 107, in f\r\n val = [scalar_validator(v) for v in s\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py\", line 107, in \u003clistcomp\u003e\r\n val = [scalar_validator(v) for v in s\r\n File \"/home/hmedina/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py\", line 285, in validate_color_for_prop_cycle\r\n raise ValueError(f\"Cannot put cycle reference ({s!r}) in prop_cycler\")\r\nValueError: Cannot put cycle reference ('C2') in prop_cycler\r\n```\r\n\r\n_Originally posted by @hmedina in https://github.com/matplotlib/matplotlib/issues/14221#issuecomment-1259779507_\r\n ","author":{"url":"https://github.com/QuLogic","@type":"Person","name":"QuLogic"},"datePublished":"2022-09-27T21:08:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/24024/matplotlib/issues/24024"}
| 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:0f0bbe94-4358-a97a-1d93-e591dafa96ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD88:1EFAFB:3CCD1E:527FDA:6A5291F6 |
| html-safe-nonce | 68bbae30b9c6ca2b6a585dfac96add6a77d4bf5bcd74f5b321652e9acb4956f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDg4OjFFRkFGQjozQ0NEMUU6NTI3RkRBOjZBNTI5MUY2IiwidmlzaXRvcl9pZCI6IjI0NzE4MTAzODcwODUwMDUzMDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9226e9b5413d9eb2cd4462b47f869327fa70c14fa28364646f83bc5477338978 |
| hovercard-subject-tag | issue:1388383142 |
| 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/24024/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ff3ae678053c9d6c31d1fcbb016fbd6a1bbacb9c008ef1c605061bc10ed0c9b4/matplotlib/matplotlib/issues/24024 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ff3ae678053c9d6c31d1fcbb016fbd6a1bbacb9c008ef1c605061bc10ed0c9b4/matplotlib/matplotlib/issues/24024 |
| og:image:alt | Usecase: I am producing various types of plots (some use rectangle collections, some regular plot-lines, some stacked plots) and wish to keep the colors synchronized across plot types for consisten... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | QuLogic |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width