Title: [Doc]: add histogram as colorbar example · Issue #30026 · matplotlib/matplotlib · GitHub
Open Graph Title: [Doc]: add histogram as colorbar example · Issue #30026 · matplotlib/matplotlib
X Title: [Doc]: add histogram as colorbar example · Issue #30026 · matplotlib/matplotlib
Description: Documentation Link No response Problem Making a colorbar histogram is a kinda popular visualization that's not difficult but I figure finnicky enough that it's worth adding an example to the gallery. Suggested improvement I've got one he...
Open Graph Description: Documentation Link No response Problem Making a colorbar histogram is a kinda popular visualization that's not difficult but I figure finnicky enough that it's worth adding an example to the galler...
X Description: Documentation Link No response Problem Making a colorbar histogram is a kinda popular visualization that's not difficult but I figure finnicky enough that it's worth adding an example to th...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/30026
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Doc]: add histogram as colorbar example","articleBody":"### Documentation Link\n\n_No response_\n\n### Problem\n\nMaking a colorbar histogram is a kinda popular visualization that's not difficult but I figure finnicky enough that it's worth adding an example to the gallery. \n\n### Suggested improvement\n\nI've got one here to explain what I mean but I'm making this an issue so that maybe someone who has a better example can have fun with this:\n\n\n\n```python\nx = np.random.random(100).reshape(10,10)\ncounts, bins = np.histogram(x)\n\ncmap = plt.colormaps['viridis']\nnorm = mcolors.BoundaryNorm(bins, cmap.N)\n\nfig, ax = plt.subplots()\nim = ax.imshow(x, cmap=cmap, norm=norm)\ncbar = plt.colorbar(im)\n\ncax = ax.inset_axes([1.5, 0, .25, 1])\nmidpoints = bins[:-1] + np.diff(bins)/2\ncax.barh(midpoints, counts, height= 1/len(counts), color = cmap(norm(midpoints)))\ncax.set_yticks(bins)\ncax.margins(0)\ncax.spines[:].set_visible(False)\n```\n\nI'm making cax an inset_axes here mostly because a lot of the real use cases for this are maps where it's nice to have a lot of control on where to put the histogram. I figure this example should live in color. Would be even nicer with #26312 and colorizer 'cause then I think the syncing is managed.\n\n","author":{"url":"https://github.com/story645","@type":"Person","name":"story645"},"datePublished":"2025-05-07T20:18:57.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/30026/matplotlib/issues/30026"}
| 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:52554740-886a-844c-1cb4-a63f25feead4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D2E4:10C4A4:1AE18E:23C0BE:6A5269D1 |
| html-safe-nonce | 91c0aaca18851fb7f220974fef14b0f950657a3b34341cc1b14017c4a31d6562 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMkU0OjEwQzRBNDoxQUUxOEU6MjNDMEJFOjZBNTI2OUQxIiwidmlzaXRvcl9pZCI6IjY1MjUxMzA2OTgzMTkzNTg0MTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 95fcf337546f5cf7bb81cd8b32632b9627062c58e5b8308d8c824b40e82e1c3b |
| hovercard-subject-tag | issue:3047080962 |
| 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/30026/issue_layout |
| twitter:image | https://opengraph.githubassets.com/23ca5b49ff808edd064b60f51578bba46b2c484a6b052ed75ab8aa586e4e483b/matplotlib/matplotlib/issues/30026 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/23ca5b49ff808edd064b60f51578bba46b2c484a6b052ed75ab8aa586e4e483b/matplotlib/matplotlib/issues/30026 |
| og:image:alt | Documentation Link No response Problem Making a colorbar histogram is a kinda popular visualization that's not difficult but I figure finnicky enough that it's worth adding an example to the galler... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | story645 |
| 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