-
Notifications
You must be signed in to change notification settings - Fork 102
Proplot colormaps cause issues with default xarray plotting #2
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
Comments
Thanks for the heads up, have never used the built-in xarray plotting commands. Indeed I switched the names for some default colormaps because I thought |
I completely agree with your thinking (and understood why you did it when I saw it). I imagine this compatibility issue would extend to any library that default plots a certain colormap like xarray. |
Decided to just tackle this right now since I'd been meaning to do something similar anyway. Latest commit should satisfy the behavior I described (hopefully) without any side-effects, using a (probably overkill) fancy new class called Try this example (after updating to the latest version): f, axs = plot.subplots(ncols=6, axwidth=2, innercolorbars='b', innercolorbars_kw={'hspace':0.2})
for i,cmap in enumerate(('ColdHot', 'HotCold', 'HotCold_r', 'RdYlGn', 'GnYlRd', 'GnYlRd_r')):
m = axs[i].contourf(np.random.rand(10,10), cmap=cmap)
axs[i].bottompanel.colorbar(m) Let me know if you discover any new issues and will re-open. |
(Accidentally left a print statement in there; latest commit will have deleted it.) |
@lukelbd, this doesn't seem to solve it on my end. Note that I did upgrade the package to the most recent commits. Using your example I get the following error:
Running ds.plot() returns the same issue as before. Interestingly, I tried to run
This happens with all submodules. Not sure if you have some lock on importing submodules directly? Although not sure how one would do that. Note that |
Hmm, The second example doesn't work because I just use the individual files to organize things ( Try accessing I wonder if when you |
It works now... can't tell you what changed. I installed via pip and your example as well as ds.plot() on anomalies works. |
Quick plots with
xarray
(e.g., ds.plot()) use 'viridis' as the default sequential colormap and 'RdBu' as the default diverging colormap.Thus, if one is to use
ds.plot()
with negative and positive values, an error is thrown because 'RdBu' doesn't exist onceproplot
is imported. For whatever reason, it seems like the 'RdBu' convention from matplotlib (https://matplotlib.org/examples/color/colormaps_reference.html) was switched to 'BuRd' inproplot
.Some other cases here are 'RdYlBu' from matplotlib becomes 'BuYlRd'. I imagine reordering of these strings should be avoided so that errors like this aren't thrown from outside packages. Perhaps simple aliases can be made to take either BuRd or RdBu.
The text was updated successfully, but these errors were encountered: