You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proplot colormaps cause issues with default xarray plotting #2
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 once proplot 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' in proplot.
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.
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 'RdBu' was a silly convention (99.9% of the time blue is "small/negative" and red is "large/positive"). Compatibility breaks didn't occur to me. I think I'll replace the colormap dictionary (stored in matplotlib.cm.cmap_d) with a new class that handles these naming issues -- total case insensitivity, and e.g. equivalency of 'RdBu_r' and 'BuRd'. Shouldn't take very long.
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 _CmapDict. See:
Running ds.plot() returns the same issue as before. Interestingly, I tried to run import proplot.colortools to just check that the new Class was showing up, and get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-30-bba849ec6737> in <module>
----> 1 import proplot.colortools
ModuleNotFoundError: No module named 'proplot.colortools'
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 import proplot works just fine, so this is isolated to submodules.
Hmm, innercolorbars_kw (which is just an alias for innerpanels_kw) should have been added by latest commit.
The second example doesn't work because I just use the individual files to organize things (__init__.py contains from .colortools import *; from .axistools import *; etc.. Wanted user to have access to all commands at the top-level (without submodules).
Try accessing plot._CmapDict; does it show anything? If not, maybe try uninstalling/re-installing. I pushed the changes.
I wonder if when you pip install from a git URL, if the version number in setup.py hasn't changed (which it hasn't), pip just won't update the repo?
Activity
lukelbd commentedon Jan 9, 2019
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
'RdBu'was a silly convention (99.9% of the time blue is "small/negative" and red is "large/positive"). Compatibility breaks didn't occur to me. I think I'll replace the colormap dictionary (stored inmatplotlib.cm.cmap_d) with a new class that handles these naming issues -- total case insensitivity, and e.g. equivalency of'RdBu_r'and'BuRd'. Shouldn't take very long.bradyrx commentedon Jan 9, 2019
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.
lukelbd commentedon Jan 9, 2019
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
_CmapDict. See:a6af853
Try this example (after updating to the latest version):
Let me know if you discover any new issues and will re-open.
lukelbd commentedon Jan 9, 2019
(Accidentally left a print statement in there; latest commit will have deleted it.)
bradyrx commentedon Jan 10, 2019
@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
import proplot.colortoolsto just check that the new Class was showing up, and get the following error: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
import proplotworks just fine, so this is isolated to submodules.lukelbd commentedon Jan 10, 2019
Hmm,
innercolorbars_kw(which is just an alias forinnerpanels_kw) should have been added by latest commit.The second example doesn't work because I just use the individual files to organize things (
__init__.pycontainsfrom .colortools import *; from .axistools import *; etc.. Wanted user to have access to all commands at the top-level (without submodules).Try accessing
plot._CmapDict; does it show anything? If not, maybe try uninstalling/re-installing. I pushed the changes.I wonder if when you
pip installfrom a git URL, if the version number insetup.pyhasn't changed (which it hasn't),pipjust won't update the repo?bradyrx commentedon Jan 10, 2019
It works now... can't tell you what changed. I installed via pip and your example as well as ds.plot() on anomalies works.