JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
469 stars 85 forks source link

colors has no field TwoSlopeNorm #581

Open xiang-yu opened 3 months ago

xiang-yu commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

Thanks a lot.