Skip to content
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

'FigureCanvasAgg' object has no attribute '_is_idle_drawing' (1.5.0rc1) #5094

Closed
mdehoon opened this issue Sep 17, 2015 · 5 comments · Fixed by #5150
Closed

'FigureCanvasAgg' object has no attribute '_is_idle_drawing' (1.5.0rc1) #5094

mdehoon opened this issue Sep 17, 2015 · 5 comments · Fixed by #5150
Assignees
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@mdehoon
Copy link
Contributor

mdehoon commented Sep 17, 2015

Using the MacOSX backend as well as other backends (e.g. the PDF backend), saving a figure to a PNG fails with 1.5.0rc1:

>>> from pylab import *
>>> figure()
<matplotlib.figure.Figure object at 0x10a387210>
>>> plot([1,2,5])
[<matplotlib.lines.Line2D object at 0x10c864a10>]
>>> savefig("test.png")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/pyplot.py", line 690, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/figure.py", line 1540, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2136, in print_figure
    canvas = self._get_output_canvas(format)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2072, in _get_output_canvas
    return self.switch_backends(canvas_class)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2296, in switch_backends
    newCanvas = FigureCanvasClass(self.figure)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 1681, in __init__
    figure.set_canvas(self)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/figure.py", line 563, in set_canvas
    self.stale = True
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 267, in stale
    self.stale_callback(self, val)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/pyplot.py", line 564, in _auto_draw_if_interactive
    fig.canvas.draw_idle()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2023, in draw_idle
    if not self._is_idle_drawing:
AttributeError: 'FigureCanvasAgg' object has no attribute '_is_idle_drawing'
>>> Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/figure.py", line 1134, in draw
    func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 2203, in draw
    self.apply_aspect()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 1329, in apply_aspect
    self.set_position(position, which='active')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/axes/_base.py", line 836, in set_position
    self.stale = True
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 267, in stale
    self.stale_callback(self, val)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/figure.py", line 56, in _stale_figure_callback
    self.figure.stale = val
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/artist.py", line 267, in stale
    self.stale_callback(self, val)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/pyplot.py", line 564, in _auto_draw_if_interactive
    fig.canvas.draw_idle()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.0rc1-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 2023, in draw_idle
    if not self._is_idle_drawing:
AttributeError: 'FigureCanvasAgg' object has no attribute '_is_idle_drawing'

This error does not occur with matplotlib 1.4.3.

@tacaswell
Copy link
Member

This is a side effect my a work-around to having stale=True immediately propagate up and call draw_idle. The previous default behavior of draw_idle was to just pass through to draw, I added a check to make sure that this draw_idle call was not triggered inside another draw_idle call to prevent very long draw times with the Agg backend if plt.ion() had been called.

I am a bit unclear on how this can be happening though as FingureCanvasAgg has no __init__ method and _is_idle_drawing is created in the __init__ of FigureCanvasBase.

Also, may try adding a test to pyplot L563 to not call draw_idle if canvas._is_saving is True.

@tacaswell tacaswell modified the milestones: next major release (2.0), next point release (1.5.0) Sep 17, 2015
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Sep 17, 2015
@tacaswell
Copy link
Member

I can not reproduce this with svg or pdf backends

Python 3.5.0 |Continuum Analytics, Inc.| (default, Sep 13 2015, 10:34:39) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'1.5.0rc1.post86+g84f2fb7'
>>> matplotlib.use('svg')
>>> import matplotlib.pyplot as plt
>>> plt.plot(range(32))
[<matplotlib.lines.Line2D object at 0x7f5c751a01d0>]
>>> plt.savefig('test.png')
>>>

@tacaswell
Copy link
Member

@efiring @jenshnielsen Can you reproduce this?

@tacaswell
Copy link
Member

Sigh, I tried to test this on a mac, but the conda-forge package does not build the osx backend (there is a note in the configuration from @pelson that travis has issues with it). Trying to source install fails as setup.py is not seeing conda's freetype headers. It also turns out I don't have xcode installed, but the current version of xcode does not support anything less than 10.10 and I don't see a way to get an old version of xcode without registering with apple. Trying brew to get gcc results in an obscure sh error (-L option not recognized) while installing a dependency which suggests that I need to install gcc (this is all probably related back to not having a c-complier though).

Bah

@tacaswell
Copy link
Member

Ah, I can reproduce this now. Had to remember that @mdehoon has plt.ion() on by default in his rcparams 😉 .

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Sep 26, 2015
If interactive mode is on using the model where every time any artist is
invalidated/marked as stale a `draw_idle` is triggered and the user is
using a non-Agg based backend, saving a png will result in a draw_idle
call triggered from inside the __init__ method of `FigureCanvasBase`
which then fails because the full object has not been set up (this is
not a problem using the IPython hooks because the stale state is only
checked once when all user code has completed executing).

closes matplotlib#5094
@tacaswell tacaswell self-assigned this Sep 26, 2015
jenshnielsen pushed a commit to jenshnielsen/matplotlib that referenced this issue Sep 27, 2015
If interactive mode is on using the model where every time any artist is
invalidated/marked as stale a `draw_idle` is triggered and the user is
using a non-Agg based backend, saving a png will result in a draw_idle
call triggered from inside the __init__ method of `FigureCanvasBase`
which then fails because the full object has not been set up (this is
not a problem using the IPython hooks because the stale state is only
checked once when all user code has completed executing).

closes matplotlib#5094
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants