Reputation: 1
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()
Upvotes: 0
Views: 590
Reputation: 160
You should try passing the levels
argument to your plot method.
See here for details.
Upvotes: 0