Matplotlib very slow

Hi,
I have compiled v.0.90.1 on RHEL 5. By default, the GTKAgg backend is being
used (TkAgg cannot be set, as TkInter is not installed on the system, I
think. It throws a "NO Module named Tkinter" error).

At any rate, a test session is as follows:
import pylab
pylab.plot ( [1,2,3],[1,2,3],'-or') #Wait for a long time, up to 3-4 minutes
pylab.show() # Display the graph. Quite fast <1sec

This delay is very unusual, and does not happen on my laptop. Does anyone have
any ideas?

Thanks!
Jose

Hi,
I have compiled v.0.90.1 on RHEL 5. By default, the GTKAgg backend is being
used (TkAgg cannot be set, as TkInter is not installed on the system, I
think. It throws a "NO Module named Tkinter" error).

At any rate, a test session is as follows:
import pylab
pylab.plot ( [1,2,3],[1,2,3],'-or') #Wait for a long time, up to 3-4 minutes
pylab.show() # Display the graph. Quite fast <1sec

This delay is very unusual, and does not happen on my laptop. Does anyone have
any ideas?

This is not happening for me. Does it happen every time you run mpl
or just the first time after you install. Run some test script, eg

  > cat test.py
  from pylab import *
  plot([1,2,3])
  show()

with

  > python test.py -dGTKAgg --verbose-debug

and see if you can get some clue what mpl is doing when it hangs.
Also, post the verbose output to the list.

Thanks,
JDH

···

On Dec 3, 2007 9:08 AM, José Gómez-Dans <jgomezdans@...287...> wrote:

John,

> I have compiled v.0.90.1 on RHEL 5. By default, the GTKAgg backend is
> being used (TkAgg cannot be set, as TkInter is not installed on the
> system, I think. It throws a "NO Module named Tkinter" error).
This is not happening for me. Does it happen every time you run mpl
or just the first time after you install. Run some test script, eg

Thanks for your reply. I think it might well be a fonts problem. Here's the
test script, plus a comment where the big delay happens:
% cat test.py
from pylab import *
plot([1,2,3])
show()
cherry% python test.py -dGTKAgg --verbose-debug
matplotlib data path /usr/lib/python2.4/site-packages/matplotlib/mpl-data
$HOME=/home/ucfajlg
CONFIGDIR=/home/ucfajlg/.matplotlib
loaded rc
file /usr/lib/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc
matplotlib version 0.90.1
verbose.level debug
interactive is False
units is True
platform is linux2
loaded modules:
['pylab', '_bisect', '__future__', 'copy_reg', 'sre_compile', 'distutils', 'itertools', '_sre', 'japanese.aliases', 'site', '__builtin__', 'datetime', 'distutils.re', 'matplotlib.re', 'matplotlib.tempfile', 'encodings', 'pytz.datetime', 'shutil', 'distutils.string', 'distutils.os', 'dateutil', 'matplotlib.datetime', 'posixpath', '_random', 'tempfile', 'errno', 'matplotlib.warnings', 'binascii', 'encodings.codecs', 'sre_constants', 're', 'matplotlib.md5', 'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig', 'encodings.exceptions', 'pytz.sets', 'math', 'fcntl', 'stat', 'zipimport', 'string', 'warnings', 'encodings.types', 'UserDict', 'encodings.utf_8', 'matplotlib', 'japanese', 'sys', 'japanese.aliases.encodings', 'pytz.tzinfo', 'pytz', '__main__', 'matplotlib.__future__', 'codecs', 'matplotlib.sys', 'matplotlib.pytz', 'types', 'md5', 'matplotlib.dateutil', 'matplotlib.os', 'thread', 'sre', 'bisect', 'matplotlib.distutils', 'signal', 'distutils.errors', 'random', 'linecache', 'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets', 'exceptions', 'sre_parse', 'pytz.bisect', 'distutils.sys', 'os', 'strop']
numerix numpy 1.0.4
font search path
['/usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf', '/usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/afm']
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSeBd.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmr10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
loaded ttfcache file /home/ucfajlg/.matplotlib/ttffont.cache
backend GTKAgg version 2.10.1
[... BIG DELAY....]
        findfont failed Bitstream Vera Serif, New Century Schoolbook, Century
Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New
Roman, Times, Palatino, Charter, serif
Could not match Bitstream Vera Serif, New Century Schoolbook, Century
Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New
Roman, Times, Palatino, Charter, serif, normal, normal.
Returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

So, it's not finding any of the fonts above, and coming up with Verta.ttf.
Could this be the problem? And if it is, what can I do to solve it?

Thanks!
Jose

···

On Tuesday 04 December 2007 03:25:15 John Hunter wrote:

On Dec 3, 2007 9:08 AM, José Gómez-Dans <jgomezdans@...287...> wrote:

Two more tests. WIll you set the debug level to
--verbose-debug-annoying and add a savefig command to your script, eg
savefig('myfig') with no extension (the backend will provide a default
extension with the -d flags below). Try running the script in three
modes

-dPS, -dAgg and -dGTKAgg

and let us know if the lag is in all three and if not in which one(s).
Then repost the debug output and insert a comment where the lag is
occurring.

Thanks,
JDH

···

On Dec 4, 2007 4:50 AM, José Gómez-Dans <jgomezdans@...287...> wrote:

Thanks for your reply. I think it might well be a fonts problem. Here's the
test script, plus a comment where the big delay happens:
% cat test.py
from pylab import *
plot([1,2,3])
show()

John,

Two more tests. WIll you set the debug level to
--verbose-debug-annoying and add a savefig command to your script, eg
savefig('myfig') with no extension (the backend will provide a default
extension with the -d flags below). Try running the script in three
modes

PS and Agg work fast enough, and produce meaningful PS and PNG output files
(as well as popping up a window with the plot). GTKAgg is the one taking a
long time to pop up, AND results in an empty PNG file. I am attaching the
debug output of the GTKAgg mode. (Delay occurs @ #[... DELAY....] line.

% cat test.py
from pylab import *
plot([1,2,3])
show()
savefig("myfig")
% python test.py -dGTKAgg --verbose-debug-annoying
matplotlib data path /usr/lib/python2.4/site-packages/matplotlib/mpl-data
$HOME=/home/ucfajlg
CONFIGDIR=/home/ucfajlg/.matplotlib
loaded rc
file /usr/lib/python2.4/site-packages/matplotlib/mpl-data/matplotlibrc
matplotlib version 0.90.1
verbose.level debug-annoying
interactive is False
units is True
platform is linux2
loaded modules:
['pylab', '_bisect', '__future__', 'copy_reg', 'sre_compile', 'distutils', 'itertools', '_sre', 'japanese.aliases', 'site', '__builtin__', '
datetime', 'distutils.re', 'matplotlib.re', 'matplotlib.tempfile', 'encodings', 'pytz.datetime', 'shutil', 'distutils.string', 'distutils.os', 'dateutil', '
matplotlib.datetime', 'posixpath', '_random', 'tempfile', 'errno', 'matplotlib.warnings', 'binascii', 'encodings.codecs', 'sre_constants', 're', 'matplotlib
.md5', 'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig', 'encodings.exceptions', 'pytz.sets', 'math', 'fcntl', 'stat', 'zipimport', 'string', 'warnin
gs', 'encodings.types', 'UserDict', 'encodings.utf_8', 'matplotlib', 'japanese', 'sys', 'japanese.aliases.encodings', 'pytz.tzinfo', 'pytz', '__main__', 'ma
tplotlib.__future__', 'codecs', 'matplotlib.sys', 'matplotlib.pytz', 'types', 'md5', 'matplotlib.dateutil', 'matplotlib.os', 'thread', 'sre', 'bisect', 'mat
plotlib.distutils', 'signal', 'distutils.errors', 'random', 'linecache', 'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets', 'exceptions', 'sre_parse
', 'pytz.bisect', 'distutils.sys', 'os', 'strop']
numerix numpy 1.0.4
font search path
['/usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf', '/usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/afm']
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSeBd.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmr10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf
trying
fontname /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
loaded ttfcache file /home/ucfajlg/.matplotlib/ttffont.cache
backend GTKAgg version 2.10.1
# [.... DELAY ....]
FigureCanvasAgg.draw
RendererAgg.__init__
RendererAgg.__init__ width=640.0, height=480.0
RendererAgg.__init__ _RendererAgg done
RendererAgg.__init__ done
RendererAgg._get_agg_font
        findfont failed Bitstream Vera Serif, New Century Schoolbook, Century
Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New
Roma
n, Times, Palatino, Charter, serif
Could not match Bitstream Vera Serif, New Century Schoolbook, Century
Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New
Roman, Times
, Palatino, Charter, serif, normal, normal.
Returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg.points_to_pixels
RendererAgg.points_to_pixels
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg._get_agg_font
RendererAgg.draw_text
RendererAgg._get_agg_font
FigureCanvasAgg.buffer_rgba
RendererAgg.buffer_rgba
FigureCanvasAgg.print_figure
FigureCanvasAgg.draw
RendererAgg.__init__
RendererAgg.__init__ width=800.0, height=600.0
RendererAgg.__init__ _RendererAgg done
RendererAgg.__init__ done

···

On Tuesday 04 December 2007 14:07:36 you wrote:

Wait a minute, if you are getting a plot window when you pass -dPS or
-dAgg, something very odd is happening and likely points to what is
causing your real problem. It means some other GUI toolkit is getting
activated and the slowness you are seeing is resulting from a conflict
between mainloops, most likely. If this is indeed the case, please
run with either -dAgg or -sPS and post the full debug annoying output.
Also, post the exact script you are running....

JDH

···

On Dec 4, 2007 8:23 AM, José Gómez-Dans <jgomezdans@...287...> wrote:

PS and Agg work fast enough, and produce meaningful PS and PNG output files
(as well as popping up a window with the plot)

Wait a minute, if you are getting a plot window when you pass -dPS or
-dAgg, something very odd is happening and likely points to what is
causing your real problem. It means some other GUI toolkit is getting
activated and the slowness you are seeing is resulting from a conflict
between mainloops, most likely. If this is indeed the case, please
run with either -dAgg or -sPS and post the full debug annoying output.
Also, post the exact script you are running....

JDH

···

On Dec 4, 2007 8:23 AM, José Gómez-Dans <jgomezdans@...287...> wrote:

PS and Agg work fast enough, and produce meaningful PS and PNG output files
(as well as popping up a window with the plot)

> PS and Agg work fast enough, and produce meaningful PS and PNG output
> files (as well as popping up a window with the plot)

Wait a minute, if you are getting a plot window when you pass -dPS or
-dAgg, something very odd is happening and likely points to what is
causing your real problem. It means some other GUI toolkit is getting
activated and the slowness you are seeing is resulting from a conflict
between mainloops, most likely. If this is indeed the case, please
run with either -dAgg or -sPS and post the full debug annoying output.

Sorry, my wrong. There's no such window when running with Agg. There was
another window from another session which I mistakenly thought had to do with
these tests. Agg and PS produce PNG and PS files respectively, with no window
popping up. Apologies for that.

Also, post the exact script you are running....

It is in the beginning of my debug output, but I'll re-send the script and
command line:

*script (test.py):
from pylab import *
plot([1,2,3])
show()
savefig("myfig")

*command line:
python test.py -dGTKAgg --verbose-debug-annoying

Thanks,
J

···

On Tuesday 04 December 2007 14:27:21 you wrote:

On Dec 4, 2007 8:23 AM, José Gómez-Dans <jgomezdans@...287...> wrote: