Title: [Bug]: Contour plot is not updating after customization made to the color bar in the generated plot. · Issue #23080 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Contour plot is not updating after customization made to the color bar in the generated plot. · Issue #23080 · matplotlib/matplotlib
X Title: [Bug]: Contour plot is not updating after customization made to the color bar in the generated plot. · Issue #23080 · matplotlib/matplotlib
Description: Bug summary A contour plot is plotted with the minimum and maximum values of the parameter as color bar limits. Then when I try to make changes (such as limits and colormap) to the color bar from the toolbar of the generated plot it is n...
Open Graph Description: Bug summary A contour plot is plotted with the minimum and maximum values of the parameter as color bar limits. Then when I try to make changes (such as limits and colormap) to the color bar from t...
X Description: Bug summary A contour plot is plotted with the minimum and maximum values of the parameter as color bar limits. Then when I try to make changes (such as limits and colormap) to the color bar from t...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/23080
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Contour plot is not updating after customization made to the color bar in the generated plot.","articleBody":"### Bug summary\n\nA contour plot is plotted with the minimum and maximum values of the parameter as color bar limits. Then when I try to make changes (such as limits and colormap) to the color bar from the toolbar of the generated plot it is not updating accordingly. \r\n\r\n1. A sample plot. \r\n\r\n2. Customizing the color bar. \r\n\r\n3. Options for changing the color bar. \r\n\r\n4. The changes are reflected in the color bar, but not in the plot. \r\nKindly suggest how I can update the plot according to the changes made in the color bar options.\n\n### Code for reproduction\n\n```python\n# A sample code.\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\n\r\norigin = 'lower'\r\n\r\ndelta = 0.025\r\n\r\nx = y = np.arange(-3.0, 3.01, delta)\r\nX, Y = np.meshgrid(x, y)\r\nZ1 = np.exp(-X**2 - Y**2)\r\nZ2 = np.exp(-(X - 1)**2 - (Y - 1)**2)\r\nZ = (Z1 - Z2) * 2\r\n\r\nnr, nc = Z.shape\r\n\r\n# put NaNs in one corner:\r\nZ[-nr // 6:, -nc // 6:] = np.nan\r\n# contourf will convert these to masked\r\n\r\n\r\nZ = np.ma.array(Z)\r\n# mask another corner:\r\nZ[:nr // 6, :nc // 6] = np.ma.masked\r\n\r\n# mask a circle in the middle:\r\ninterior = np.sqrt(X**2 + Y**2) \u003c 0.5\r\nZ[interior] = np.ma.masked\r\n\r\nfig1, ax2 = plt.subplots(constrained_layout=True)\r\nCS = ax2.contourf(X, Y, Z, 10, cmap=plt.cm.bone, origin=origin)\r\n\r\n# Note that in the following, we explicitly pass in a subset of the contour\r\n# levels used for the filled contours. Alternatively, we could pass in\r\n# additional levels to provide extra resolution, or leave out the *levels*\r\n# keyword argument to use all of the original levels.\r\n\r\nCS2 = ax2.contour(CS, levels=CS.levels[::2], colors='r', origin=origin)\r\n\r\nax2.set_title('Nonsense (3 masked regions)')\r\nax2.set_xlabel('word length anomaly')\r\nax2.set_ylabel('sentence length anomaly')\r\n\r\n# Make a colorbar for the ContourSet returned by the contourf call.\r\ncbar = fig1.colorbar(CS)\r\ncbar.ax.set_ylabel('verbosity coefficient')\r\n# Add the contour line levels to the colorbar\r\ncbar.add_lines(CS2)\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\r\n\n\n### Expected outcome\n\n\r\n\r\nThe following changes have been made to the code in order to get the expected plot.\r\n`lev = np.linspace(-0.5, 0.5, 10)`\r\n`CS = ax2.contourf(X, Y, Z, 10, cmap=plt.cm.rainbow, origin=origin, levels=lev)`\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.4.3\n\n### Matplotlib Backend\n\nQt5Agg\n\n### Python version\n\nPython 3.8.12\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\npip","author":{"url":"https://github.com/JishnuJeevan","@type":"Person","name":"JishnuJeevan"},"datePublished":"2022-05-20T06:57:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/23080/matplotlib/issues/23080"}
| 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:e09cb477-586c-a3ca-bd30-0e0dcb5b265c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A1D4:9B0A:9F9EB1:E8FDC7:6A56026C |
| html-safe-nonce | 7eed6f76a99608e8276cdb201947fd4dbcb4a7ba33f3382fc35356f797cdba43 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMUQ0OjlCMEE6OUY5RUIxOkU4RkRDNzo2QTU2MDI2QyIsInZpc2l0b3JfaWQiOiIzMDg5MTM4MzAyOTY1OTA4MDc2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 71bdce9c1f252af003610ba1f4e91ee52925a77492c6b836196426f8902c2ed6 |
| hovercard-subject-tag | issue:1242713017 |
| 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/23080/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0988a93b153c4e8e128136d6726ea6f04ec3472c33a842636c618a180d5b4eeb/matplotlib/matplotlib/issues/23080 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0988a93b153c4e8e128136d6726ea6f04ec3472c33a842636c618a180d5b4eeb/matplotlib/matplotlib/issues/23080 |
| og:image:alt | Bug summary A contour plot is plotted with the minimum and maximum values of the parameter as color bar limits. Then when I try to make changes (such as limits and colormap) to the color bar from t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JishnuJeevan |
| hostname | github.com |
| expected-hostname | github.com |
| None | f4368738fc918fecd9b3958f6b49218bbe60d4185f38e72e3954e11f1ad0213a |
| 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 | ed27e29ef37c0e8f612ea3fed8118b955b8314e2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width