-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmap.set_under() does not work as expected #3590
Comments
Thanks for the report @johnomotani. I expect we are recreating the colormap from scratch somewhere in |
Might be somethnig to do with xarray/xarray/plot/dataset_plot.py Line 137 in ed05f98
? The docstring for
|
No that's for dataset plotting and is a norm for size of points plotted by I would look here: Lines 77 to 101 in ed05f98
|
Looks like that was it, thanks @dcherian! |
As a workaround (until #3601) is finished you can do: import matplotlib
from matplotlib import pyplot
from xarray import DataArray
import numpy
da = DataArray(numpy.linspace(0, 1)[numpy.newaxis, :]*numpy.linspace(0, 1)[:, numpy.newaxis])
cmap = matplotlib.cm.viridis
h = da.plot.contourf(vmin=.3, cmap=cmap)
cmap = h.get_cmap()
cmap.set_under('w')
h.set_cmap(cmap) |
When using matplotlib, the
set_under()
method can be used to set values below the range of a colormap to a certain color, for exampleproduces

while uncommenting the

cmap.set_under()
call producesHowever, using
xarray
to do the same thing,produces

where it seems the call to
cmap.set_under('w')
had no effect. Expected behaviour would be output like the second plot.Output of
xr.show_versions()
The text was updated successfully, but these errors were encountered: