Open zxdawn opened 1 year ago
This seems to be a conflict between xarray and proplot plotting utilities where vmin
and vmax
are not respected for TwoSlopeNorm
... strange that the error does not seem to occur for other normalizers. (Edit: I found the error also occurs for proplot DivergingNorm
-- so seems to be related to the handling of normalizers with a vcenter
).
It appears that a workaround for now is to use ax.pcolor(z, ...)
instead of z.plot(ax=ax, ...)
.
Xarray command (version 2022.3.0
):
import numpy as np
import proplot as pplt
import matplotlib.colors as mcolors
import xarray as xr
x, y = np.meshgrid(np.linspace(0,50,51), np.linspace(0,50,51))
z = np.linspace(-2,4,50*50).reshape(50,50)
fig, ax = pplt.subplots()
norm = mcolors.TwoSlopeNorm(vcenter=0)
z = xr.DataArray(z)
z.plot(ax=ax, vmin=-1, vmax=3, norm=norm, cmap='burd')
Proplot command (version 0.9.5.post339
):
import numpy as np
import proplot as pplt
import matplotlib.colors as mcolors
import xarray as xr
x, y = np.meshgrid(np.linspace(0,50,51), np.linspace(0,50,51))
z = np.linspace(-2,4,50*50).reshape(50,50)
fig, ax = pplt.subplots()
norm = mcolors.TwoSlopeNorm(vcenter=0)
z = xr.DataArray(z)
ax.pcolor(z, vmin=-1, vmax=3, norm=norm, cmap='burd', discrete=False, colorbar='r', extend='both')
Description
The TwoSlopeNorm doesn't work with proplot.
Steps to reproduce
Expected behavior:
Actual behavior:
Equivalent steps in matplotlib
Proplot version
Paste the results of
import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)
here.