PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

colors has no field TwoSlopeNorm

Open xiang-yu opened this issue 1 year ago • 2 comments
trafficstars

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() 

xiang-yu avatar Mar 19 '24 15:03 xiang-yu

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)

stevengj avatar Mar 19 '24 19:03 stevengj

Thanks a lot.

xiang-yu avatar Mar 24 '24 20:03 xiang-yu