Giter Club home page Giter Club logo

Comments (7)

lukelbd avatar lukelbd commented on May 17, 2024

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.

from proplot.

bradyrx avatar bradyrx commented on May 17, 2024

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.

from proplot.

lukelbd avatar lukelbd commented on May 17, 2024

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):

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.

from proplot.

lukelbd avatar lukelbd commented on May 17, 2024

(Accidentally left a print statement in there; latest commit will have deleted it.)

from proplot.

bradyrx avatar bradyrx commented on May 17, 2024

@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:

TypeError                                 Traceback (most recent call last)
<ipython-input-27-9b7beea59934> in <module>
----> 1 f, axs = plot.subplots(ncols=6, axwidth=2, innercolorbars='b', innercolorbars_kw={'hspace':0.2})
      2 for i,cmap in enumerate(('ColdHot', 'HotCold', 'HotCold_r', 'RdYlGn', 'GnYlRd', 'GnYlRd_r')):
      3     m = axs[i].contourf(np.random.rand(10,10), cmap=cmap)
      4     axs[i].bottompanel.colorbar(m)

~/Desktop/proplot/proplot/subplots.py in subplots(array, ncols, nrows, rowmajor, emptycols, emptyrows, tight, auto_adjust, rcreset, silent, span, share, spanx, spany, sharex, sharey, innerpanels, innercolorbars, innerpanels_kw, basemap, proj, projection, proj_kw, projection_kw, **kwargs)
    262 
    263     # Create gridspec for outer plotting regions (divides 'main area' from side panels)
--> 264     figsize, offset, subplots_kw, gridspec_kw = _gridspec_kwargs(nrows, ncols, **kwargs)
    265     row_offset, col_offset = offset
    266     gs = FlexibleGridSpec(**gridspec_kw)

TypeError: _gridspec_kwargs() got an unexpected keyword argument 'innercolorbars_kw'

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.

from proplot.

lukelbd avatar lukelbd commented on May 17, 2024

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?

from proplot.

bradyrx avatar bradyrx commented on May 17, 2024

It works now... can't tell you what changed. I installed via pip and your example as well as ds.plot() on anomalies works.

from proplot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.