[Python-modules-team] Bug#548874: Bug#548874: matplotlib: figure() call fails. GTK seems not to recognise filetype of a .svg file
Jonas
wayne.stoerts at googlemail.com
Wed Oct 7 14:14:37 UTC 2009
hi,
as the original backtrace indicates, the svg problem is related to the gtkagg
backend (which is default), in particular to the window icon:
/usr/lib/pymodules/python2.5/matplotlib/backends/backend_gtk.pyc in
__init__(self, canvas, num)
441 self.window.set_title("Figure %d" % num)
442 if (window_icon):
--> 443 self.window.set_icon_from_file(window_icon)
444
445 self.vbox = gtk.VBox()
GError: Couldn't recognize the image file format for file
'/usr/share/matplotlib/mpl-data/images/matplotlib.svg'
(see the original post for full backtrace)
> I tried to replicate this problem in a clean chroot and only maplotlib
> installed (and its dependencies of course) but the svg file is
> generated correctly *without* any svg library installed.
>
> The code I used is:
>
> import matplotlib as mpl
> mpl.use('SVG')
> import matplotlib.pyplot as plt
> plt.figure()
> plt.plot([1,2])
> plt.savefig('test.svg')
> python -c "import matplotlib as mpl ; print mpl.__version__"
> 0.99.0
same version as i have.
The problem arises when GTK creates a window and is told to load an icon in
SVG format for which GTK needs a gdk-pixbuf loader for SVG. This is provided
by librsvg2-common.
When using the matplotlib svg backend, no window will be created at all.
When using the qt4agg backend, the window is provided by QT instead of GTK,
and the error also won't occur.
To reproduce this problem, deinstall librsvg2-common and use the following
python code:
import matplotlib as mpl
# explicitly set gtkagg as backend. usually it is default
mpl.use('gtkagg')
import matplotlib.pyplot as plt
plt.figure()
as librsvg2-common is amongst the dependencies of gnome you usually won't see
this error if you have gnome installed, which is default for debian.
More information about the Python-modules-team
mailing list