Title: [ENH]: Voxels as mappable for colorbar · Issue #22969 · matplotlib/matplotlib · GitHub
Open Graph Title: [ENH]: Voxels as mappable for colorbar · Issue #22969 · matplotlib/matplotlib
X Title: [ENH]: Voxels as mappable for colorbar · Issue #22969 · matplotlib/matplotlib
Description: Problem Hi; I'm working with 3D plots and I use colored voxels to plots a 4th dimension. When one wants to use a colorbar, one usually uses an image or a contourf in the colorbar creation method like so : img = ax.imshow(event, **cmap_ar...
Open Graph Description: Problem Hi; I'm working with 3D plots and I use colored voxels to plots a 4th dimension. When one wants to use a colorbar, one usually uses an image or a contourf in the colorbar creation method li...
X Description: Problem Hi; I'm working with 3D plots and I use colored voxels to plots a 4th dimension. When one wants to use a colorbar, one usually uses an image or a contourf in the colorbar creation metho...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22969
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[ENH]: Voxels as mappable for colorbar","articleBody":"### Problem\n\nHi;\r\n\r\nI'm working with 3D plots and I use colored voxels to plots a 4th dimension.\r\n\r\nWhen one wants to use a colorbar, one usually uses an image or a contourf in the colorbar creation method like so : \r\n\r\n```\r\nimg = ax.imshow(event, **cmap_args)\r\nplt.colorbar(img)\r\n```\r\n\r\nIt is very handful to handle all the colormap arguments (such as vmin etc) directly from the image but doesn't work with voxels.\r\n\r\n\r\nCurrently I use this : \r\n\r\n\r\n`\r\n\r\n palette=mpl.cm.get_cmap(\"viridis\",lut=levels).copy() #simulate the level arg of other plot methods\r\n palette.set_under((0,0,0,0)) #So vmin has an effect\r\n if add_colorbar:\r\n \r\n vmax = np.max(NPArr) #NPArr is the data being plotted\r\n norm = mpl.colors.Normalize(0,vmax) #Necessary because there is no mappable from voxels, instead of normalizing the data it is easier to normalize the \"cmap\"\r\n m = cm.ScalarMappable(cmap=palette,norm=norm) #Creates Mappable\r\n m.set_array([]) #Makes it the right type so get() methods exist\r\n ticks = np.linspace(1,vmax,levels+1)\r\n fig.colorbar(m, ax=ax, extend=\"min\", ticks=ticks) #Finally creates the cmap with other cmap arguments that can't be passed to the mappable\r\n\r\n`\r\n\r\n\r\nVoxels give dictionnary of 3d objet so I have tried to use one of its value as mappable which works but doesn't bring all the data info for the colormap.\n\n### Proposed solution\n\n_No response_","author":{"url":"https://github.com/Luluser","@type":"Person","name":"Luluser"},"datePublished":"2022-05-04T11:35:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":13},"url":"https://github.com/22969/matplotlib/issues/22969"}
| 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:288253de-e022-1926-0902-215160019387 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A8E4:147EC0:A6B00D:DE9338:6A527D6A |
| html-safe-nonce | b8b6e036f90618692fa636007f96dfbc3847a129bb8c8bae858b9971c4d7b446 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBOEU0OjE0N0VDMDpBNkIwMEQ6REU5MzM4OjZBNTI3RDZBIiwidmlzaXRvcl9pZCI6IjQyMDA4OTk2NDk5MTYyNzE5NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d32a5dbc8e3cfc451b2d5e4a58b6b1f5beb4bb7d9a44381ea1758d9eb4af1629 |
| hovercard-subject-tag | issue:1225250306 |
| 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/22969/issue_layout |
| twitter:image | https://opengraph.githubassets.com/752f3a3ae138dfdeb3afb2f7049f528e796faf070724494d840c2ac350f22edc/matplotlib/matplotlib/issues/22969 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/752f3a3ae138dfdeb3afb2f7049f528e796faf070724494d840c2ac350f22edc/matplotlib/matplotlib/issues/22969 |
| og:image:alt | Problem Hi; I'm working with 3D plots and I use colored voxels to plots a 4th dimension. When one wants to use a colorbar, one usually uses an image or a contourf in the colorbar creation method li... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Luluser |
| 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