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
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.savefig('test.jpg', dpi=150) # or whatever dpi you want
If you are only using savefig, not plotting to the screen, then you might as well use the agg backend, not the gtkagg.
Eric
···
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
But changing the dpi value has no effect so maybe I'm missing something.
The figure dpi is irrelevant when saving the figure; only the dpi specified in the savefig command matters for that. This is inherently confusing. I'm thinking about a solution, but haven't tried it yet.
Thanks for your comments and thanks for your working example, Goyo.
Eric Firing <efiring@...202...>:
If you are only using savefig, not plotting to the screen, then you might as
well use the agg backend, not the gtkagg.
I have previously used the agg backend without any problems. The
reason I am switching to GTK(Agg) is because I would like to save some
of my plots in jpeg (which only the GTK backend supports). In some
tests that I have made (manually converting png plots to jpeg with
PIL) it seems like this will result in much smaller plots that are
still in good quality. My application serves plots over the internet
so file size is quite important.