how to make matplotlib faster?

But that made me wonder whether or not there was a need for

    > some sort of switch that delayed any update for just this
    > case where one is looping over many plots (say you wrote a
    > ploting function that did this that you want to run in
    > interactive mode, and you wanted to use basic plotting
    > functions like plot). Is there a simple mechanism to turn
    > off interactive mode temporarily within the function and
    > restore it at the end? If not, could it be added? (akin to
    > the hold() function)

Aside from the aforementioned "run" mode of ipython, which does just
this, the basic incantation is

  >>> from matplotlib import interactive, is_interactive
  >>> b = is_interactive() # store the current interactive state
  >>> plot(blah, blah) # make some plots
  >>> interactive(False) # turn interactive off
  >>> for i in arange(1e4096): plot(arange(i), arange(i)**2) # don't try this at home
  >>> interactive(b) # restore previous interactive state

Basically, this is what ipython does. This is wrapped into a single
function "run", called like

  >>> x = 1 # some fluff
  >>> run ~/myexamples/simple_demo.py # turn interactive off for run
  >>> x = 2 # interactive setting is restored

But of course, you can use the interactive / is_interactive functions
in any script or interactive session.

To make this more accessible, perhaps we should add an interactive (or
update) kwarg to plot and friends, in the same vein that we discussed
a kwarg for hold, so you can easily do things like

  plot(x, y, hold=False) # add plot, clearing previous
  plot(x, y, update=False) # add plot but do not update

But the question arises, does the additional complexity in the
matplotlib internals required to support this justify the savings for
the occasional user who would otherwise have to type a couple of extra
lines?

JDH

John Hunter Wrote:>

Aside from the aforementioned "run" mode of ipython, which does just
this, the basic incantation is

  >>> from matplotlib import interactive, is_interactive
  >>> b = is_interactive() # store the current interactive state
  >>> plot(blah, blah) # make some plots
  >>> interactive(False) # turn interactive off
  >>> for i in arange(1e4096): plot(arange(i), arange(i)**2) #
don't try this at home
  >>> interactive(b) # restore previous interactive state

Basically, this is what ipython does. This is wrapped into a single
function "run", called like

  >>> x = 1 # some fluff
  >>> run ~/myexamples/simple_demo.py # turn interactive off for run
  >>> x = 2 # interactive setting is restored

But of course, you can use the interactive / is_interactive functions
in any script or interactive session.

To make this more accessible, perhaps we should add an interactive (or
update) kwarg to plot and friends, in the same vein that we discussed
a kwarg for hold, so you can easily do things like

  plot(x, y, hold=False) # add plot, clearing previous
  plot(x, y, update=False) # add plot but do not update

But the question arises, does the additional complexity in the
matplotlib internals required to support this justify the savings for
the occasional user who would otherwise have to type a couple of extra
lines?

In this case I don't think so. the function interactive() is what
I was looking for, not a keyword argument. Unlike overplotting,
I think interactive() is likely to be used almost entirely in
scripts and functions and that is by far the better approach.
So it's already good enough as far as I'm concerned.

Perry

···

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options