Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colors has no field TwoSlopeNorm #581

Open
xiang-yu opened this issue Mar 19, 2024 · 2 comments
Open

colors has no field TwoSlopeNorm #581

xiang-yu opened this issue Mar 19, 2024 · 2 comments

Comments

@xiang-yu
Copy link

Hi everyone,

It appears that "colors" function imported from matplotlib does not have "Normalize" or "TwoSlopeNorm" field.
Any idea about this?

using PyPlot
vmin, vmax = -1, 1
norm = colors.TwoSlopeNorm(vmin=vmin, vcenter=0., vmax=vmax)

ERROR: type #colors has no field TwoSlopeNorm

Anyways, my goal is to set the colorbar zero at center with symmetric color range.

pcolormesh(data, cmap="RdBu_r", norm = norm, shading="auto")
Colorbar() 
@stevengj
Copy link
Member

colors in PyPlot is currently a wrapper function, not the underlying Python object. If you want the underlying Python object, you can use matplotlib.colors:

matplotlib.colors.TwoSlopeNorm(vmin=vmin, vcenter=0., vmax=vmax)

@xiang-yu
Copy link
Author

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants