Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[ENH]: Voxels as mappable for colorbar #22969

Open
Labels
@Luluser

Description

@Luluser

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_args)plt.colorbar(img)

It is very handful to handle all the colormap arguments (such as vmin etc) directly from the image but doesn't work with voxels.

Currently I use this :

`

palette=mpl.cm.get_cmap("viridis",lut=levels).copy()     #simulate the level arg of other plot methodspalette.set_under((0,0,0,0))                             #So vmin has an effectif add_colorbar:vmax = np.max(NPArr)                                    #NPArr is the data being plottednorm = 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"m = cm.ScalarMappable(cmap=palette,norm=norm)           #Creates Mappablem.set_array([])                                         #Makes it the right type so get() methods existticks = np.linspace(1,vmax,levels+1)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

`

Voxels 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.

Proposed solution

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp