I want to get a plot a colormap with discrete intervals, each interval associated to a color. My dataset is in xarray and works well. I tried the code below but I get the following error. I tried with norm.vmax=100 and without. Any help is welcome.
ValueError: Passing a Normalize instance simultaneously with vmin/vmax is not supported. Please pass vmin/vmax directly to the norm when creating it.
fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(10, 7))
cmap = mpl.colors.ListedColormap(['blue', 'yellow', 'red'])
bounds = np.array([0, 1, 5,100]) norm = mpl.colors.BoundaryNorm(bounds, cmap.N)
norm.vmax=100 norm.vmin=0
ds_p.plot(cmap=cmap, norm=norma, cbar_kwargs={'pad' :0.1, 'shrink': 0.5, 'label': '[% of year]'}) plt.show()
Robert
9,08661 gold badges194 silver badges215 bronze badges
1 Answer 1
You should try passing the levels argument to your plot method.
See here for details.
answered Oct 27, 2023 at 19:33
jamespolly
1601 silver badge10 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-py