how to make matplotlib faster?

Hi, 1. slow plot 2. cursor issue 3. key press event !

    > ------- 1/ Here is the piece of code which is quite slow I
    > think. Compared to pgplot this is a factor of more than
    > 10. It does first draw a default plot (0,1 ?) and then
    > overplot on it for each subplot.

    > for this particular case I have 10 subplots. The slices are
    > made of about 10-20 points each only (stored in a 3D array
    > which is 48x5x20 points). I hope this answers the
    > question. Sorry for the ''specifics''.

Plots of this size should be extremely fast - you should be able to
plot arrays 10 times this big with good performance. From your
description "It does first draw a default plot ..and then overplot on
it for each subplot." it sounds like you may have interactive mode
turned on. This would kill your performance in a case like this,
because the entire figure would be redrawn with the update of every
single plotting command. See
http://matplotlib.sourceforge.net/interactive.html and
http://matplotlib.sourceforge.net/faq.html#SHOW .

To definitively determine what mode you are in, run your script with

> python simple_plot.py --verbose-helpful

and verify that 'interactive is False'. Fernando Perez's ipython has
support for running scripts from the interactive shell, turning off
interactive mode for the duration of the run, and then restoring it.

If this doesn't solve your problem please

  - post your entire script

  - report the output of verbose-helpful (requires matplotlib 0.64)

  - what is your platform, machine specs, etc?

  - how are you running the script (IDE, from the command prompt, etc)

JDH

John Hunter wrote:

Plots of this size should be extremely fast - you should be able to
plot arrays 10 times this big with good performance. From your
description "It does first draw a default plot ..and then overplot on
it for each subplot." it sounds like you may have interactive mode
turned on. This would kill your performance in a case like this,
because the entire figure would be redrawn with the update of every
single plotting command. See
http://matplotlib.sourceforge.net/interactive.html and
http://matplotlib.sourceforge.net/faq.html#SHOW .

To definitively determine what mode you are in, run your script with

> python simple_plot.py --verbose-helpful

and verify that 'interactive is False'. Fernando Perez's ipython has
support for running scripts from the interactive shell, turning off
interactive mode for the duration of the run, and then restoring it.

I wondered the same thing and mentioned that to him privately
(in effect you are doing n*(n-1)/2 plots instead of n).

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)

Perry