Title: Doc: MidpointNormalize example should point to DivergingNorm as a built-in function · Issue #14892 · matplotlib/matplotlib · GitHub
Open Graph Title: Doc: MidpointNormalize example should point to DivergingNorm as a built-in function · Issue #14892 · matplotlib/matplotlib
X Title: Doc: MidpointNormalize example should point to DivergingNorm as a built-in function · Issue #14892 · matplotlib/matplotlib
Description: I've seen many folks seeking a way to set 0 as the midpoint in a color bar. I wonder if this MidpointNormalize subclass could be added into matplotlib as a builtin function. The following code is copied from the doc. import numpy as np i...
Open Graph Description: I've seen many folks seeking a way to set 0 as the midpoint in a color bar. I wonder if this MidpointNormalize subclass could be added into matplotlib as a builtin function. The following code is c...
X Description: I've seen many folks seeking a way to set 0 as the midpoint in a color bar. I wonder if this MidpointNormalize subclass could be added into matplotlib as a builtin function. The following code ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/14892
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Doc: MidpointNormalize example should point to DivergingNorm as a built-in function","articleBody":"I've seen many folks seeking a way to set 0 as the midpoint in a color bar. I wonder if this `MidpointNormalize` subclass could be added into matplotlib as a builtin function.\r\n\r\nThe following code is copied from the [doc](https://matplotlib.org/3.1.1/gallery/userdemo/colormap_normalizations_custom.html#sphx-glr-gallery-userdemo-colormap-normalizations-custom-py).\r\n```python\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib.colors as colors\r\n\r\nN = 100\r\n'''\r\nCustom Norm: An example with a customized normalization. This one\r\nuses the example above, and normalizes the negative data differently\r\nfrom the positive.\r\n'''\r\nX, Y = np.mgrid[-3:3:complex(0, N), -2:2:complex(0, N)]\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\n\r\n# Example of making your own norm. Also see matplotlib.colors.\r\n# From Joe Kington: This one gives two different linear ramps:\r\nclass MidpointNormalize(colors.Normalize):\r\n def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):\r\n self.midpoint = midpoint\r\n colors.Normalize.__init__(self, vmin, vmax, clip)\r\n\r\n def __call__(self, value, clip=None):\r\n # I'm ignoring masked values and all kinds of edge cases to make a\r\n # simple example...\r\n x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]\r\n return np.ma.masked_array(np.interp(value, x, y))\r\n\r\n\r\n#####\r\nfig, ax = plt.subplots(2, 1)\r\n\r\npcm = ax[0].pcolormesh(X, Y, Z,\r\n norm=MidpointNormalize(midpoint=0.),\r\n cmap='RdBu_r')\r\nfig.colorbar(pcm, ax=ax[0], extend='both')\r\n\r\npcm = ax[1].pcolormesh(X, Y, Z, cmap='RdBu_r', vmin=-np.max(Z))\r\nfig.colorbar(pcm, ax=ax[1], extend='both')\r\n\r\nplt.show()\r\n```\r\n\r\n","author":{"url":"https://github.com/stevenlis","@type":"Person","name":"stevenlis"},"datePublished":"2019-07-26T03:15:01Z","url":"https://github.com/matplotlib/matplotlib/issues/14892"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:21c2172d-1b86-a5d2-24d9-2ddbd805d428 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8980:20DDCE:FE2B73:1541AEF:6B065550 |
| html-safe-nonce | 1424875a9f9c0ce2bb4aa3710b5cca580da24a0096adf74c9daf1a43503c4830 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4OTgwOjIwRERDRTpGRTJCNzM6MTU0MUFFRjo2QjA2NTU1MCIsInZpc2l0b3JfaWQiOiI3NTkyODE3MTU1MzE0NzAxNjQ4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 9f40e574aad7afddc0923a8fe7d7fc6f6685e0f00151e80ff70e8b1536bd0a97 |
| hovercard-subject-tag | issue:473156782 |
| 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/14892/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f3aad0359d439a32611ba3e4352341333104784377d1d3b5e2c47c678986d559/matplotlib/matplotlib/issues/14892 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f3aad0359d439a32611ba3e4352341333104784377d1d3b5e2c47c678986d559/matplotlib/matplotlib/issues/14892 |
| og:image:alt | I've seen many folks seeking a way to set 0 as the midpoint in a color bar. I wonder if this MidpointNormalize subclass could be added into matplotlib as a builtin function. The following code is c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stevenlis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6324e6ac990fb6befbec840cc0e102a1071c339bfe8f9826bb12de2e3ba1d297 |
| 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 | 7f0aa75f4141d440c6110dc31af7ea7797abb6c4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width