Slow interactive plotting

I'm trying to get approx 4k points plotted into 5 subplots which I would
like interactive (ie: ability to zoom/pan ...).
there's nothing special except that the subplots share axe x.

It gets some seconds (3 to 5) on a p4 dual core @ 3Ghz to pan/zoom. It
seems utterly slow to me: what do you think? normal "rate" or flawed code?
I tried using various backend, embedding it into qt4 ... nothing helped
much.

the code is quite fat atm (500 lines or so). I'll try to cut through the
code to get an example in a few lines if it's said my code is flawed and
the plotting rate should be way faster!

···

----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.

Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----

Instead of starting with your cod,e start from scratch and see if you
can reproduce the problem. If not, figure out what is different and
work your way up. Here is some test code -- note that Eric Firing
made a contribution on the svn trunk that significantly speeds up this
use case:

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
Nplots = 5
Npoints = 5000
for i in range(Nplots):
    if i==0:
        ax = ax1 = fig.add_subplot(Nplots,1,i+1)
    else:
        ax = fig.add_subplot(Nplots,1,i+1, sharex=ax1)

    ax.plot(np.random.rand(Npoints))

ax.set_xlim(100, 200)
plt.show()

···

On Mon, May 18, 2009 at 10:23 AM, guillaume ranquet <granquet@...2572...> wrote:

I'm trying to get approx 4k points plotted into 5 subplots which I would
like interactive (ie: ability to zoom/pan ...).
there's nothing special except that the subplots share axe x.

It gets some seconds (3 to 5) on a p4 dual core @ 3Ghz to pan/zoom. It
seems utterly slow to me: what do you think? normal "rate" or flawed code?
I tried using various backend, embedding it into qt4 ... nothing helped
much.

the code is quite fat atm (500 lines or so). I'll try to cut through the
code to get an example in a few lines if it's said my code is flawed and
the plotting rate should be way faster!

I think I put a finger on what breaks the performance, thx to your
snippet of code.
I forgot to mention that I'm using some axvlines here and there (500 per
subplot).
it goes from slow to _unacceptably_ slow with the axvlines.

I'm using the axvlines to mark some events that I need to know about in
order to have an explanation of the variations of the curves.
any advice on what to use to replace those?

···

On Mon, May 18, 2009 at 10:23 AM, guillaume ranquet <granquet@...2572...> wrote:

> I'm trying to get approx 4k points plotted into 5 subplots which I would
> like interactive (ie: ability to zoom/pan ...).
> there's nothing special except that the subplots share axe x.
>
>
> It gets some seconds (3 to 5) on a p4 dual core @ 3Ghz to pan/zoom. It
> seems utterly slow to me: what do you think? normal "rate" or flawed code?
> I tried using various backend, embedding it into qt4 ... nothing helped
> much.
>
> the code is quite fat atm (500 lines or so). I'll try to cut through the
> code to get an example in a few lines if it's said my code is flawed and
> the plotting rate should be way faster!

Instead of starting with your cod,e start from scratch and see if you
can reproduce the problem. If not, figure out what is different and
work your way up. Here is some test code -- note that Eric Firing
made a contribution on the svn trunk that significantly speeds up this
use case:

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
Nplots = 5
Npoints = 5000
for i in range(Nplots):
    if i==0:
        ax = ax1 = fig.add_subplot(Nplots,1,i+1)
    else:
        ax = fig.add_subplot(Nplots,1,i+1, sharex=ax1)

    ax.plot(np.random.rand(Npoints))

ax.set_xlim(100, 200)
plt.show()

----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.

Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----

There is no function axvlines -- there is vlines and axvline. If you
are making repeated calls to axvline you may be creating a whole bunch
of individual line objects and that will kill your performance. A
LineCollection will help here

http://matplotlib.sourceforge.net/search.html?q=codex+LineCollection

···

On Mon, May 18, 2009 at 11:20 AM, guillaume ranquet <granquet@...2572...> wrote:

I'm using the axvlines to mark some events that I need to know about in
order to have an explanation of the variations of the curves.
any advice on what to use to replace those?

guillaume ranquet wrote:

I'm trying to get approx 4k points plotted into 5 subplots which I would
like interactive (ie: ability to zoom/pan ...).
there's nothing special except that the subplots share axe x.

It gets some seconds (3 to 5) on a p4 dual core @ 3Ghz to pan/zoom. It
seems utterly slow to me: what do you think? normal "rate" or flawed code?
I tried using various backend, embedding it into qt4 ... nothing helped
much.

the code is quite fat atm (500 lines or so). I'll try to cut through the
code to get an example in a few lines if it's said my code is flawed and
the plotting rate should be way faster!

Instead of starting with your cod,e start from scratch and see if you
can reproduce the problem. If not, figure out what is different and
work your way up. Here is some test code -- note that Eric Firing
made a contribution on the svn trunk that significantly speeds up this
use case:

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
Nplots = 5
Npoints = 5000
for i in range(Nplots):
    if i==0:
        ax = ax1 = fig.add_subplot(Nplots,1,i+1)
    else:
        ax = fig.add_subplot(Nplots,1,i+1, sharex=ax1)

    ax.plot(np.random.rand(Npoints))

ax.set_xlim(100, 200)
plt.show()

I think I put a finger on what breaks the performance, thx to your
snippet of code.
I forgot to mention that I'm using some axvlines here and there (500 per
subplot).

(That's quite a lot...)

it goes from slow to _unacceptably_ slow with the axvlines.

Yes, it is generating a lot of draw events.

I'm using the axvlines to mark some events that I need to know about in
order to have an explanation of the variations of the curves.
any advice on what to use to replace those?

Possibilities include a LineCollection, or a single line with markers. I suspect a single line with masked points used to break it up into vertical segments would also work, although I don't know how fast it would be. The markers approach would be fastest, I suspect.

Eric

···

On Mon, May 18, 2009 at 10:23 AM, guillaume ranquet <granquet@...2572...> wrote:

----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.

Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

guillaume ranquet wrote:

I'm trying to get approx 4k points plotted into 5 subplots which I

would

like interactive (ie: ability to zoom/pan ...).
there's nothing special except that the subplots share axe x.

It gets some seconds (3 to 5) on a p4 dual core @ 3Ghz to pan/zoom. It
seems utterly slow to me: what do you think? normal "rate" or

flawed code?

I tried using various backend, embedding it into qt4 ... nothing helped
much.

the code is quite fat atm (500 lines or so). I'll try to cut

through the

code to get an example in a few lines if it's said my code is

flawed and

the plotting rate should be way faster!

Instead of starting with your cod,e start from scratch and see if you
can reproduce the problem. If not, figure out what is different and
work your way up. Here is some test code -- note that Eric Firing
made a contribution on the svn trunk that significantly speeds up this
use case:

import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
Nplots = 5
Npoints = 5000
for i in range(Nplots):
    if i==0:
        ax = ax1 = fig.add_subplot(Nplots,1,i+1)
    else:
        ax = fig.add_subplot(Nplots,1,i+1, sharex=ax1)

    ax.plot(np.random.rand(Npoints))

ax.set_xlim(100, 200)
plt.show()

I think I put a finger on what breaks the performance, thx to your
snippet of code.
I forgot to mention that I'm using some axvlines here and there (500 per
subplot).

(That's quite a lot...)

it goes from slow to _unacceptably_ slow with the axvlines.

Yes, it is generating a lot of draw events.

I'm using the axvlines to mark some events that I need to know about in
order to have an explanation of the variations of the curves.
any advice on what to use to replace those?

Possibilities include a LineCollection, or a single line with markers. I
suspect a single line with masked points used to break it up into
vertical segments would also work, although I don't know how fast it
would be. The markers approach would be fastest, I suspect.

Eric

----
This message contains confidential information and may contain

information that is legally privileged. If you have received this
message by mistake, please immediately notify us and delete the original
message. Thank you.

Ce message contient des informations confidentielles. S'il vous est

parvenu par erreur, merci de bien vouloir nous en aviser par retour, de
n'en faire aucun usage et de n'en garder aucune copie.

···

On Mon, May 18, 2009 at 10:23 AM, guillaume ranquet <granquet@...2572...> wrote:

----

------------------------------------------------------------------------------

Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited

royalty-free distribution of the report engine for externally facing
server and web deployment. http://p.sf.net/sfu/businessobjects

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

thanks for your help,
I got it solved ! turning the axvline()s into a LineCollection gave a
slight improvement ... but switching to wxPython gave a great boost of
performance!
I guess there's a performance problem with embedding in QT4?

my problem is solved since Wx will do as go as QT. :slight_smile:
----
This message contains confidential information and may contain information that is legally privileged. If you have received this message by mistake, please immediately notify us and delete the original message. Thank you.

Ce message contient des informations confidentielles. S'il vous est parvenu par erreur, merci de bien vouloir nous en aviser par retour, de n'en faire aucun usage et de n'en garder aucune copie.
----