Title: [Bug]: Change in ListedColormap behavior in 3.10.0 · Issue #29504 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Change in ListedColormap behavior in 3.10.0 · Issue #29504 · matplotlib/matplotlib
X Title: [Bug]: Change in ListedColormap behavior in 3.10.0 · Issue #29504 · matplotlib/matplotlib
Description: Bug summary While running integration tests on a package that I maintain I'm seeing a change in the behavior of ListedColormap in 3.10.0. This appears to be a regression and is causing significant changes in some of the imagery that my t...
Open Graph Description: Bug summary While running integration tests on a package that I maintain I'm seeing a change in the behavior of ListedColormap in 3.10.0. This appears to be a regression and is causing significant ...
X Description: Bug summary While running integration tests on a package that I maintain I'm seeing a change in the behavior of ListedColormap in 3.10.0. This appears to be a regression and is causing signific...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29504
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Change in ListedColormap behavior in 3.10.0","articleBody":"### Bug summary\n\nWhile running integration tests on a package that I maintain I'm seeing a change in the behavior of `ListedColormap` in 3.10.0. This appears to be a regression and is causing significant changes in some of the imagery that my tests produce.\n\nThe tests are baked into a larger system and would be difficult for matplotlib maintainers to replicate, so I wrote up a dummy script that, I think, shows the problem. I'm not sure if it is capturing the full problem or not but it's at least capturing part of it.\n\n### Code for reproduction\n\n```Python\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom matplotlib.colors import ListedColormap\nfrom matplotlib import __version__ as mpl_vers\n\n\ncld_type_colors = [\n \"ghostwhite\",\n \"slategray\",\n \"blue\",\n \"royalblue\",\n \"cyan\",\n \"limegreen\",\n \"green\",\n \"yellow\",\n \"gold\",\n \"lightsalmon\",\n \"coral\",\n \"red\",\n \"maroon\",\n \"black\",\n]\n\n\nrainbow_colors = [\n (255, 0, 0), # Red\n (255, 64, 0), # Reddish-Orange\n (255, 128, 0), # Orange\n (255, 192, 0), # Yellowish-Orange\n (255, 255, 0), # Yellow\n (192, 255, 0), # Yellowish-Green\n (128, 255, 0), # Greenish-Yellow\n (0, 255, 0), # Green\n (0, 255, 128), # Greenish-Cyan\n (0, 255, 192), # Cyan\n (0, 255, 255), # Bright Cyan\n (0, 192, 255), # Bluish-Cyan\n (0, 128, 255), # Blue\n (0, 64, 255), # Blueish-Purple\n (64, 0, 255), # Purple\n (128, 0, 255), # Violet\n]\nrainbow_colors = [(r / 255, g / 255, b / 255) for r, g, b in rainbow_colors]\n\ncld_type_cmap = ListedColormap(cld_type_colors, name=\"cld_type_cmap\")\nrainbow_cmap = ListedColormap(rainbow_colors, name=\"rainbow_cmap\")\n\n# Create 1600x1600 array constant values in the vertial and float values ranging from\n# 0-15 in the horizontal\nsize = 1600\nnum_values = 16\nh_vals = np.linspace(0, num_values - 1, size)\nflt_array = np.tile(h_vals, (size, 1))\n\n# Plot float values using the cloud type colormap\nfig, ax = plt.subplots(figsize=(10, 10))\nax.set_title(\"Float - Cloud Type Color Map - MPL Version: \" + mpl_vers)\nax.imshow(flt_array, cmap=cld_type_cmap)\nfig.savefig(f\"float_cloud_type_{mpl_vers.replace('.', '')}.png\")\n\n# Plot float values using the rainbow colormap\nfig, ax = plt.subplots(figsize=(10, 10))\nax.set_title(\"float - Rainbow Color Map - MPL Version: \" + mpl_vers)\nax.imshow(flt_array, cmap=rainbow_cmap)\nfig.savefig(f\"float_rainbow_{mpl_vers.replace('.', '')}.png\")\n\n# Create a 1600x1600 array constant values in the vertial and integer values ranging\n# from 0-15 in the horizontal\nh_vals = np.arange(0, 16)\nh_vals = np.repeat(h_vals, size // len(h_vals))\nint_array = np.tile(h_vals, (size, 1))\n\n# Plot integer values using the cloud type colormap\nfig, ax = plt.subplots(figsize=(10, 10))\nax.set_title(\"Integer - Cloud Type Color Map - MPL Version: \" + mpl_vers)\nax.imshow(int_array, cmap=cld_type_cmap)\nfig.savefig(f\"int_cloud_type_{mpl_vers.replace('.', '')}.png\")\n\n# Plot integer values using the rainbow colormap\nfig, ax = plt.subplots(figsize=(10, 10))\nax.set_title(\"Integer - Rainbow Color Map - MPL Version: \" + mpl_vers)\nax.imshow(int_array, cmap=rainbow_cmap)\nfig.savefig(f\"int_rainbow_{mpl_vers.replace('.', '')}.png\")\n```\n\n### Actual outcome\n\n### With v3.10.0 I get the following images. If you zoom in on the borders between color bands, you will see some lines of different color.\n\n\n\n\n\n\n\n\n\n### Zoomed in:\n\n\n\n\n\n\n\n\n\n\n\n### Expected outcome\n\n### With v3.9.4 I get the following output. If you zoom in on the borders between the color bands, there is a sharp transition between bands with no extra colors.\n\n\n\n\n\n\n\n\n\n### Zoomed in:\n\n\n\n\n\n\n\n\n\n### Additional information\n\nJust for additional context, below are the really ugly images produced by our integration tests. The changes in how the colormaps are applied appear to be the cause of some of the differences here, though I don't think they actually address everything.\n\n### 3.10.0\n\n\n\n### 3.9.4\n\n\n\n### Operating system\n\nRocky\n\n### Matplotlib Version\n\n3.10.0\n\n### Matplotlib Backend\n\nagg\n\n### Python version\n\n3.10.16\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/jsolbrig","@type":"Person","name":"jsolbrig"},"datePublished":"2025-01-22T21:51:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/29504/matplotlib/issues/29504"}
| 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:46756e18-e37a-55f7-46da-3e465d1a88b9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CEBA:240794:930B19:C2DCB4:6A531463 |
| html-safe-nonce | d0df3fb26386271f6a21b5a0236ab445715d1143721ef08e755a6d55b51c1229 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRUJBOjI0MDc5NDo5MzBCMTk6QzJEQ0I0OjZBNTMxNDYzIiwidmlzaXRvcl9pZCI6IjU5NDQzOTMxNTUwMjE1NzUyNjciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ae841d6dfebe065b5a90004db8a7e14f8f00f16efc763b9f27b5c1d981956145 |
| hovercard-subject-tag | issue:2805420731 |
| 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/29504/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e98fec7a17b02d9caf41f76e37dddcbda0a87e512f4e49f94398ea9965435fe4/matplotlib/matplotlib/issues/29504 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e98fec7a17b02d9caf41f76e37dddcbda0a87e512f4e49f94398ea9965435fe4/matplotlib/matplotlib/issues/29504 |
| og:image:alt | Bug summary While running integration tests on a package that I maintain I'm seeing a change in the behavior of ListedColormap in 3.10.0. This appears to be a regression and is causing significant ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jsolbrig |
| 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