matplotlib.pyplot.pcolor and matplotlib.pyplot.savefig unexpectedly slow

Hello all,
I am a matplotlib novice so I expect I am doing something inappropriate.

From the attached script (matplotlib-slow.py), it will be seen that I
am creating a 512x512 (numpy) array and using matplotlib to plot it.
Below is the script output on my Microsoft Windows XP (service pack 3)
box:

matplotlib-slow.py
[2009-04-13 08:40:34] [DEBUG ] [line # 23] Python version: 2.5.4
(r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
[2009-04-13 08:40:34] [DEBUG ] [line # 24] numpy version: 1.2.1
[2009-04-13 08:40:34] [DEBUG ] [line # 25] matplotlib version:
0.98.5.2
[2009-04-13 08:40:34] [DEBUG ] [line # 37] executing
matplotlib.pyplot.subplot()
[2009-04-13 08:40:34] [DEBUG ] [line # 39]
executing matplotlib.pyplot.pcolor()

[2009-04-13 08:41:12] [DEBUG ] [line # 41] executing
matplotlib.pyplot.colorbar()
[2009-04-13 08:41:12] [DEBUG ] [line # 45]
executing matplotlib.pyplot.savefig()

[2009-04-13 08:41:35] [DEBUG ] [line # 47] executing
matplotlib.pyplot.close()

Note, the call to pcolor() and savefig() consume 38 and 13 seconds
respectively. My goal is to dramatically reduce these times (1 second
or less).

I would appreciate your suggestions.

Thanks,

– jv

matplotlib-slow.py (1.84 KB)

Is there any particular reason that you have to use pcolor?

My understanding is that the imshow is the fastest.
Also, pcolormesh is much faster than pcolor if you use agg backend.
Your script runs in a second on my linux box if I replace pcolor with
pcolormesh.

-JJ

···

On Mon, Apr 13, 2009 at 10:54 AM, Jim Vickroy <Jim.Vickroy@...259...> wrote:

Hello all,

I am a matplotlib novice so I expect I am doing something inappropriate.

>From the attached script (matplotlib-slow.py), it will be seen that I am
creating a 512x512 (numpy) array and using matplotlib to plot it.

Below is the script output on my Microsoft Windows XP (service pack 3) box:

<session>

matplotlib-slow.py

[2009-04-13 08:40:34] [DEBUG ] [line # 23] Python version: 2.5.4
(r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
[2009-04-13 08:40:34] [DEBUG ] [line # 24] numpy version: 1.2.1
[2009-04-13 08:40:34] [DEBUG ] [line # 25] matplotlib version: 0.98.5.2
[2009-04-13 08:40:34] [DEBUG ] [line # 37] executing
matplotlib.pyplot.subplot()
[2009-04-13 08:40:34] [DEBUG ] [line # 39] executing
matplotlib.pyplot.pcolor()
[2009-04-13 08:41:12] [DEBUG ] [line # 41] executing
matplotlib.pyplot.colorbar()
[2009-04-13 08:41:12] [DEBUG ] [line # 45] executing
matplotlib.pyplot.savefig()
[2009-04-13 08:41:35] [DEBUG ] [line # 47] executing
matplotlib.pyplot.close()
</session>

Note, the call to pcolor() and savefig() consume 38 and 13 seconds
respectively. My goal is to dramatically reduce these times (1 second or
less).

I would appreciate your suggestions.

Thanks,
-- jv

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Jae-Joon Lee wrote:

Is there any particular reason that you have to use pcolor?
  

None whatsoever; it is simply what I first encountered in an example.

My understanding is that the imshow is the fastest.
Also, pcolormesh is much faster than pcolor if you use agg backend.
Your script runs in a second on my linux box if I replace pcolor with
pcolormesh.
  

I saw pcolormesh() documented but did not understand its significance. I struggle to understand all of the matplotlib variants.

Substituting pcolormesh() for pcolor(), my script now also runs in under a second on my Microsoft box -- an amazing difference!

Thanks very much for your quick response!

-- jv

···

-JJ

On Mon, Apr 13, 2009 at 10:54 AM, Jim Vickroy <Jim.Vickroy@...259...> wrote:
  

Hello all,

I am a matplotlib novice so I expect I am doing something inappropriate.

>From the attached script (matplotlib-slow.py), it will be seen that I am
creating a 512x512 (numpy) array and using matplotlib to plot it.

Below is the script output on my Microsoft Windows XP (service pack 3) box:

<session>
    

matplotlib-slow.py
      

[2009-04-13 08:40:34] [DEBUG ] [line # 23] Python version: 2.5.4
(r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)]
[2009-04-13 08:40:34] [DEBUG ] [line # 24] numpy version: 1.2.1
[2009-04-13 08:40:34] [DEBUG ] [line # 25] matplotlib version: 0.98.5.2
[2009-04-13 08:40:34] [DEBUG ] [line # 37] executing
matplotlib.pyplot.subplot()
[2009-04-13 08:40:34] [DEBUG ] [line # 39] executing
matplotlib.pyplot.pcolor()
[2009-04-13 08:41:12] [DEBUG ] [line # 41] executing
matplotlib.pyplot.colorbar()
[2009-04-13 08:41:12] [DEBUG ] [line # 45] executing
matplotlib.pyplot.savefig()
[2009-04-13 08:41:35] [DEBUG ] [line # 47] executing
matplotlib.pyplot.close()
</session>

Note, the call to pcolor() and savefig() consume 38 and 13 seconds
respectively. My goal is to dramatically reduce these times (1 second or
less).

I would appreciate your suggestions.

Thanks,
-- jv

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users