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

Non-interactive backend calls draw more than 100 times · Issue #4780 · matplotlib/matplotlib · GitHub

Repository navigation

Non-interactive backend calls draw more than 100 times #4780

Closed

Description

This code:

import matplotlib
matplotlib.use('agg')
from pylab import *
plot([1,2,5])
savefig("test")

causes Figure.draw to be called 155 times with the code currently in master.
With matplotlib 1.4.3, Figure.draw is called twice (once to create the PNG, and once to redraw the figure).
I am guessing that this has to do with the default implementation of draw_idle in FigureCanvasBase. Currently it calls draw().
So then if I change a property of the figure, the figure gets marked as stale, draw_idle is called, draw_idle calls draw, which resets the figure as non-stale.

Activity

  1. WeatherGod commented on Jul 24, 2015

    Member

    Could this possibly be addressed by #4738?

    On Fri, Jul 24, 2015 at 5:54 AM, mdehoon notifications@github.com wrote:

    This code:

    import matplotlib
    matplotlib.use('agg')from pylab import *
    plot([1,2,5])
    savefig("test")

    causes Figure.draw to be called 155 times with the code currently in
    master.
    With matplotlib 1.4.3, Figure.draw is called twice (once to create the
    PNG, and once to redraw the figure).
    I am guessing that this has to do with the default implementation of
    draw_idle in FigureCanvasBase. Currently it calls draw().
    So then if I change a property of the figure, the figure gets marked as
    stale, draw_idle is called, draw_idle calls draw, which resets the figure
    as non-stale.

    —
    Reply to this email directly or view it on GitHub
    #4780.

  2. tacaswell commented on Jul 24, 2015

    Member

    It is fixed by #4738 which is now a couple of changes merged together.

  3. mdehoon commented on Nov 13, 2015

    ContributorAuthor

    With 1.5.0, the example above before the call to savefig causes five calls to Figure.draw.
    With the pdf, svg, and interactive backends, there is only one call to Figure.draw.

  4. tacaswell commented on Nov 13, 2015

    Member

    This is because Agg does not actually have an asynchronous draw_idle call, just a safely re-entrant one. The extra 4 draw calls from the various figure/axes construction steps where a synchronous draw is forced every time an attribute is changed. This is a consequence of calling draw_idle on every flip to stale.

    If you turn interactive mode off you will not get the extra draws (as the hook isn't installed) or if you run this in IPython (as we use their post execute hooks to get the asynchronous draw instead of relying on the backends to provide it) you will not get the extra draws.

    The svg and pdf backends don't have a functional draw method (their main logic is in the print_* methods iirc).

    Maybe we should raise when interactive mode is enabled with non-interactive backends, but that seems like a lot of extra complication for not much payoff.

    I am in favor of closing this issue as I don't think we can do better than this in the case where

    1. interactive mode is enabled (so auto-redraw)
    2. the user is using a non-interactive backend
  5. mdehoon commented on Nov 13, 2015

    ContributorAuthor

    I don't have a strong opinion on this matter. I'm OK with closing this issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL