FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

axes_grid1 axes have no keyword argument 'bbox_extra_artists' · Issue #12634 · matplotlib/matplotlib · GitHub

Repository navigation

axes_grid1 axes have no keyword argument 'bbox_extra_artists' #12634

Closed

Description

Bug report

Bug summary

A regression was introduced from v3.0.0 and v3.0.1 that breaks axes_grid1 with a TypeError: get_tightbbox() got an unexpected keyword argument 'bbox_extra_artists'.

Code for reproduction

import matplotlib.pyplot as plt
plt.ion()

from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset

fig, ax = plt.subplots(figsize=(8, 6))

l, = ax.plot([1, 2, 3], [0, 1, 0])

ax_zoom = zoomed_inset_axes(ax, 4)
ax_zoom.plot([1, 2, 3], [0, 1, 0])

mark_inset(ax, ax_zoom, loc1=1, loc2=3, fc="none", ec='0.3')

fig.savefig("/tmp/tmp.png")

Actual outcome

TypeError                                 Traceback (most recent call last)
~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/IPython/core/pylabtools.py in <lambda>(fig)
    239 
    240     if 'png' in formats:
--> 241         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    242     if 'retina' in formats or 'png2x' in formats:
    243         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/IPython/core/pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs)
    123 
    124     bytes_io = BytesIO()
--> 125     fig.canvas.print_figure(bytes_io, **kw)
    126     data = bytes_io.getvalue()
    127     if fmt == 'svg':

~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, **kwargs)
   2051                     bbox_artists = kwargs.pop("bbox_extra_artists", None)
   2052                     bbox_inches = self.figure.get_tightbbox(renderer,
-> 2053                             bbox_extra_artists=bbox_artists)
   2054                     pad = kwargs.pop("pad_inches", None)
   2055                     if pad is None:

~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/matplotlib/figure.py in get_tightbbox(self, renderer, bbox_extra_artists)
   2274         bb.extend(
   2275             ax.get_tightbbox(renderer, bbox_extra_artists=bbox_extra_artists)
-> 2276             for ax in self.axes if ax.get_visible())
   2277 
   2278         if len(bb) == 0:

~/.miniconda36/envs/poliastro37/lib/python3.7/site-packages/matplotlib/figure.py in <genexpr>(.0)
   2274         bb.extend(
   2275             ax.get_tightbbox(renderer, bbox_extra_artists=bbox_extra_artists)
-> 2276             for ax in self.axes if ax.get_visible())
   2277 
   2278         if len(bb) == 0:

TypeError: get_tightbbox() got an unexpected keyword argument 'bbox_extra_artists'

<Figure size 576x432 with 2 Axes>

Expected outcome

This worked in version v3.0.0.

Matplotlib version

  • Operating system: Linux Mint (latest)
  • Matplotlib version: v3.0.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.7.0
  • Jupyter version (if applicable): 5.7.0 (notebook)
  • Other libraries:

Installed using pip.

Activity

  1. jklymak commented on Oct 26, 2018

    Member

    I cannot reproduce with the code above, thought I didn't try with the inline backend. I do get a wonky looking figure, but I don't throw an error.

  2. jklymak commented on Oct 26, 2018

    Member

    OK. I see - you forgot to specify fig.savefig("/tmp/tmp.png", box_inches='tight')

  3. added this to the v3.0.x milestone on Oct 26, 2018
  4. tylerharvey commented on Dec 11, 2018

    I get the same error in 3.0.1 with inset_axes(). I see that they're supposed to be experimental now, but the code I'm using worked before 3.0.0 (I don't remember if I ran it with 3.0.0 as well).

    import matplotlib.pyplot as plt
    import numpy as np
    from mpl_toolkits.axes_grid1.inset_locator import inset_axes
    fig = plt.figure()
    ax1 = plt.gca()
    ax1.plot(np.arange(10))
    inset_ax1 = inset_axes(ax1,width="50%",height=0.6)
    inset_ax1.plot(np.arange(10))
    plt.savefig('inset_axes_test',pad_inches=0,bbox_inches='tight')
    

    Outcome:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/local/lib/python3.5/dist-packages/matplotlib/pyplot.py", line 689, in savefig
        res = fig.savefig(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py", line 2094, in savefig
        self.canvas.print_figure(fname, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/matplotlib/backend_bases.py", line 2053, in print_figure
        bbox_extra_artists=bbox_artists)
      File "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py", line 2276, in get_tightbbox
        for ax in self.axes if ax.get_visible())
      File "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py", line 2276, in <genexpr>
        for ax in self.axes if ax.get_visible())
    TypeError: get_tightbbox() got an unexpected keyword argument 'bbox_extra_artists'
    

    I get no bug with bbox_inches=0 or None.

  5. jklymak commented on Dec 11, 2018

    Member

    I don’t think this was fixed until 3.0.2, but I could be wrong.

    The experimental inset_axes is not imported from axes_grid1. It is just a method on axes. I.e. inset = ax1.inset_axes().

  6. tylerharvey commented on Dec 18, 2018

    Yep, you're right that it's fixed in 3.0.2.

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

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL