I can't make much sense of this. You don't plot anything and don't use
canvas.

This code works:

import matplotlib
matplotlib.use('GTKAgg')
from matplotlib import pyplot
pyplot.plot([0, 1, 2, 3], [0, 1, 2, 3])
fig = pyplot.gcf()
fig.savefig('test.jpg')

But I don't know how to set the dpi value this way. I tried to use the
OO API but no success.

Goyo

El dom, 12-10-2008 a las 23:45 +0200, Jesper Larsen escribió:
> Hi matplotlib-users,
> 
> I decided to try to make some plots that I have previously made in png
> format using the Agg backend in jpeg format using the GTKAgg backend
> (which I guess is the one I should use for this). Unfortunately my
> script exits with an error. I have therefore created a simple test
> script (test.py) that illustrates the problem (at least on my
> computer):
> 
> import matplotlib
> from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as
> FigureCanvas
> 
> fig = matplotlib.figure.Figure(dpi=100)
> canvas = FigureCanvas(fig)
> fig.savefig('test.jpg')
> 
> When I run it I get:
> 
> $ python test.py
> /usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:357:
> GtkWarning: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED
> (widget) || GTK_IS_INVISIBLE (widget)' failed
>   gtk.DrawingArea.realize(self)
> /usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:360:
> GtkWarning: gdk_pixmap_new: assertion `(drawable != NULL) || (depth !=
> -1)' failed
>   pixmap = gdk.Pixmap (self.window, width, height)
> Traceback (most recent call last):
>   File "test.py", line 6, in <module>
>     fig.savefig('test.jpg')
>   File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line
> 964, in savefig
>     self.canvas.print_figure(*args, **kwargs)
>   File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py",
> line 1310, in print_figure
>     **kwargs)
>   File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py",
> line 347, in print_jpeg
>     return self._print_image(filename, 'jpeg')
>   File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py",
> line 360, in _print_image
>     pixmap = gdk.Pixmap (self.window, width, height)
> RuntimeError: could not create GdkPixmap object
> 
> I am using matplotlib 0.98.3, pygtk 2.14.0. My system is a Linux Ubuntu:
> 
> $ uname -a
> Linux <blanket out> #1 SMP Wed Aug 20 18:39:13 UTC 2008 i686 GNU/Linux
> 
> Does anyone know what is wrong?
> 
> Best regards,
> Jesper
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to