Skip to content

Oldest compatible matplotlib version? #114

Closed

Description

@mickaellalande

I tried to upgrade ProPlot and install it with conda install -c conda-forge proplot recently and I'm facing to errors every time I'm trying to put a colorbar. Here is the example of the documentation (https://proplot.readthedocs.io/en/latest/colorbars_legends.html#Axes-colorbars-and-legends):

import proplot as plot
import numpy as np
with plot.rc.context(abc=True):
    f, axs = plot.subplots(ncols=2, share=0)

# Colorbars
ax = axs[0]
state = np.random.RandomState(51423)
m = ax.heatmap(state.rand(10, 10), colorbar='t', cmap='dusk')
ax.colorbar(m, loc='r')
ax.colorbar(m, loc='ll', label='colorbar label')
ax.format(title='Axes colorbars', suptitle='Axes colorbars and legends demo')

# Legends
ax = axs[1]
ax.format(title='Axes legends', titlepad='0em')
hs = ax.plot(
    (state.rand(10, 5) - 0.5).cumsum(axis=0), linewidth=3,
    cycle='sharp', legend='t',
    labels=list('abcde'), legend_kw={'ncols': 5, 'frame': False}
)
ax.legend(hs, loc='r', ncols=1, frame=False)
ax.legend(hs, loc='ll', label='legend label')
axs.format(xlabel='xlabel', ylabel='ylabel')

Here is the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-19-837a2de5d36a> in <module>
      7 ax = axs[0]
      8 state = np.random.RandomState(51423)
----> 9 m = ax.heatmap(state.rand(10, 10), colorbar='t', cmap='dusk')
     10 ax.colorbar(m, loc='r')
     11 ax.colorbar(m, loc='ll', label='colorbar label')

~/anaconda3/lib/python3.7/site-packages/proplot/axes.py in heatmap(self, *args, **kwargs)
   1208         that is suitable for heatmaps: no gridlines, no minor ticks, and major
   1209         ticks at the center of each grid box."""
-> 1210         obj = self.pcolormesh(*args, **kwargs)
   1211         xlocator, ylocator = None, None
   1212         if hasattr(obj, '_coordinates'):

~/anaconda3/lib/python3.7/site-packages/proplot/wrappers.py in _wrapper(self, *args, **kwargs)
   2960         @functools.wraps(func)
   2961         def _wrapper(self, *args, **kwargs):
-> 2962             return driver(self, func, *args, **kwargs)
   2963         name = func.__name__
   2964         if name not in proplot_methods:

~/anaconda3/lib/python3.7/site-packages/proplot/wrappers.py in standardize_2d(self, func, order, globe, *args, **kwargs)
    650     colorbar_kw = kwargs.pop('colorbar_kw', None) or {}
    651     colorbar_kw.setdefault('label', colorbar_label)
--> 652     return func(self, x, y, *Zs, colorbar_kw=colorbar_kw, **kwargs)
    653 
    654 

~/anaconda3/lib/python3.7/site-packages/proplot/wrappers.py in _wrapper(self, *args, **kwargs)
   2960         @functools.wraps(func)
   2961         def _wrapper(self, *args, **kwargs):
-> 2962             return driver(self, func, *args, **kwargs)
   2963         name = func.__name__
   2964         if name not in proplot_methods:

~/anaconda3/lib/python3.7/site-packages/proplot/wrappers.py in cmap_changer(self, func, cmap, cmap_kw, extend, norm, norm_kw, N, levels, values, centers, vmin, vmax, locator, symmetric, locator_kw, edgefix, labels, labels_kw, fmt, precision, colorbar, colorbar_kw, panel_kw, lw, linewidth, linewidths, ls, linestyle, linestyles, color, colors, edgecolor, edgecolors, *args, **kwargs)
   2128         if loc != 'fill':
   2129             colorbar_kw.setdefault('loc', loc)
-> 2130         self.colorbar(obj, **colorbar_kw)
   2131     return obj
   2132 

~/anaconda3/lib/python3.7/site-packages/proplot/axes.py in colorbar(self, loc, pad, length, width, space, frame, frameon, alpha, linewidth, edgecolor, facecolor, *args, **kwargs)
    944         # Generate panel
    945         if loc in ('left', 'right', 'top', 'bottom'):
--> 946             ax = self.panel_axes(loc, width=width, space=space, filled=True)
    947             return ax.colorbar(loc='_fill', *args, length=length, **kwargs)
    948 

~/anaconda3/lib/python3.7/site-packages/proplot/axes.py in panel_axes(self, side, **kwargs)
   1370             The panel axes.
   1371         """
-> 1372         return self.figure._add_axes_panel(self, side, **kwargs)
   1373 
   1374     @_standardize_1d

~/anaconda3/lib/python3.7/site-packages/proplot/utils.py in decorator(*args, **kwargs)
     61         if BENCHMARK:
     62             t = time.perf_counter()
---> 63         res = func(*args, **kwargs)
     64         if BENCHMARK:
     65             decorator.time += (time.perf_counter() - t)

~/anaconda3/lib/python3.7/site-packages/proplot/subplots.py in _add_axes_panel(self, ax, side, filled, **kwargs)
    858         gridspec_prev = self._gridspec_main
    859         gridspec = self._insert_row_column(
--> 860             side, iratio, width, space, space_orig, figure=False)
    861         if gridspec is not gridspec_prev:
    862             if s == 't':

~/anaconda3/lib/python3.7/site-packages/proplot/subplots.py in _insert_row_column(self, side, idx, ratio, space, space_orig, figure)
   1339             # May seem inefficient but it literally just assigns a hidden,
   1340             # attribute, and the creation time for subpltospecs is tiny
-> 1341             axs = [iax for ax in self._iter_axes()
   1342                    for iax in (ax, *ax.child_axes)]
   1343             for ax in axs:

~/anaconda3/lib/python3.7/site-packages/proplot/subplots.py in <listcomp>(.0)
   1340             # attribute, and the creation time for subpltospecs is tiny
   1341             axs = [iax for ax in self._iter_axes()
-> 1342                    for iax in (ax, *ax.child_axes)]
   1343             for ax in axs:
   1344                 # Get old index

AttributeError: 'XYAxesSubplot' object has no attribute 'child_axes'

Here is the version of ProPlot:

# Name                    Version                   Build  Channel
proplot                   0.3.1                      py_1    conda-forge

There were no problems in previous versions... This error is the same for any other plots I'm trying to do.

Activity

  1. lukelbd commented on Jan 21, 2020

    @lukelbd
    Collaborator

    Weird... Axes.child_axes is a part of the public matplotlib API, don't know why it would be missing.

    Could you first try upgrading both matplotlib and proplot with conda upgrade matplotlib proplot? Latest version of proplot is 0.4.3.

    This is probably a local issue / dependency issue; the travis tests and the RTD build were successful.

    (Note conda install doesn't upgrade to the latest version if it's already installed.)

  2. lukelbd commented on Jan 21, 2020

    @lukelbd
    Collaborator

    FWIW tried this example after running conda install proplot=0.3.1 on my machine and it worked.

  3. mickaellalande commented on Jan 21, 2020

    @mickaellalande
    ContributorAuthor

    Humm ok yes I guess it is a problem of my environment that I upgraded recently... I tried a new environment and it works fine (with both version of ProPlot 0.4.3 a,d 0.3.1 too). Maybe it is coming from matplotlib that have matplotlib-base 2.2.4 in my base environment (probably a conflict with other packages...?)

    Test on new env:

    matplotlib                3.1.1            py37h5429711_0  
    matplotlib-base           3.1.1            py37hfd891ef_0    conda-forge
    

    My base env:

    matplotlib                3.1.1            py37h5429711_0  
    matplotlib-base           2.2.4            py37hfd891ef_0    conda-forge
    

    Anyway, I'll figure out, it must be a problem of my environment, not ProPlot :)

  4. changed the title [-]Colorbar raise AttributeError in recent version[/-] [+]Oldest compatible matplotlib version?[/+] on Jan 21, 2020
  5. lukelbd commented on Jan 21, 2020

    @lukelbd
    Collaborator

    Ah, thought this might happen! This is related to conda-forge/proplot-feedstock#3.

    ProPlot has switched the depencencies from matplotlib-base (only available on the conda-forge channel) to matplotlib (available both on the conda-forge and default channels, and what I expect most people already have installed). I made this change precisely because for most users, the matplotlib-base dependency results in dual installations of matplotlib (as you have), and for some reason often results in conda downloading a really old matplotlib-base.

    But either way, version 2.X should not have been installed. I need to precisely figure out the oldest compatible version of matplotlib (i.e. the dependencies should be something like matplotlib>=3.0.0 or matplotlib-base>=3.0.0 instead of just matplotlib and matplotlib-base) and update the existing conda forge builds. Will leave this open until I get around to it

  6. mickaellalande commented on Jan 22, 2020

    @mickaellalande
    ContributorAuthor

    Ah, thought this might happen! This is related to conda-forge/proplot-feedstock#3.

    I am actually a bit lost between conda and conda-forge... I went to read this page: https://conda-forge.org/docs/user/tipsandtricks.html#multiple-channels, do you advise to have as they recommend at the end:

    $ cat .condarc
    channel_priority: strict
    channels:
      - conda-forge
      - defaults
    

    or stay with the default behavior of Anaconda/Miniconda (unless we have any issue...)?

  7. lukelbd commented on Jan 22, 2020

    @lukelbd
    Collaborator

    In the past I avoided this because having to search the conda-forge channel does slow things down compared to defaults, but since they've made some performance improvements I decided to do this. Also I like that conda forge is the open source answer to CA's default channel formulas, and that they have so many packages available.

  8. added this to the Version 0.10 milestone on Jul 21, 2021
  9. lukelbd commented on Jan 24, 2022

    @lukelbd
    Collaborator

    Ok... I've been doing some testing with different matplotlib versions/conda environments and while recent proplot versions have had issues with matplotlib < 3.2.0, the next proplot release should be backwards compatible to 3.0.0 (see d192811).

    In #310 I'll have a couple build matrices for new and old versions to prevent making backwards-incompatible changes, and in general from here on out the miminimum/maximum compatible matplotlib versions will be more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions