python-matplotlib and wxmpl

wxmpl is a nice library for implementing matplotlib-plots in wxpython-GUIs.

However, it is not always synchronised with the latest matplotlib. So, a rather careless system update to matplotlib 0.98 (major makeover somewhere) from the packman repo quite efficiently disables wxmpl 1.2.9:
"ImportError: cannot import name Point" (from matplotlib.transforms)... and so on...
0.91 works - there is a SuSE package in the Education repository, add
ftp5.gwdg.de/pub/opensuse/repositories/Education/desktop/openSUSE_10.3/ in YaST (or openSUSE_11.0, note that the URL dropped a ":" since I last edited this post) - and while you're at it, protect your python packages against updates ;-)

On the matplotlib Sourceforge mailing list, someone has posted an inofficial updated version, which should be OK with matplotlib-0.98. However, they dropped 3d plotting support from matplotlib > 0.91, so maybe it's still advisable to stick to older versions. Update: 3d plotting is going to be back in in 0.99 (see here). Yay!
Note that there seems to be some bug with numpy's histogram function: if you set the normed keyword, you might get a
TypeError: 'NoneType' object is not iterable error.

Note: I've been experiencing segmentation faults at calling pylab.show() from a wxpython application. In my case this was due to the matplotlib using the wrong backend:
If there is no file ~/.matplotlib/matplotlibrc, copy it from /usr/lib/python2.5/site-packages/matplotlib/mpl-data/matplotlibrc.
Edit the "backend"-line to WxAgg:
# the default backend; one of GTK GTKAgg GTKCairo FltkAgg QtAgg TkAgg
# WX WXAgg Agg Cairo GD GDK Paint PS PDF SVG Template
backend: WXAgg

Alternative: import the packages in exactly this order:
$ import matplotlib
$ matplotlib.use('WXAgg')
$ import pylab

On the other hand, calling pylab.show() repeatedly with the 'WXAgg' backend from a non wx-environment (e.g. a shell) can result in blank or crashing figure windows starting from the second call. Use some other backend, for example 'GTKAgg', following the example above.

No comments: