> When the image wont fit on the default letter page,
> backend_ps tries to find a page it will fit on. It turns
> out that the C0-C6 page sizes were causing problems, I
> guess they are not postscript approved. This is fixed in
>> Hey Darren,
>> Thanks for the quick fix. It now fits on the page, but does
>> not appear to be centered -- see attachment below. If I recall
>> correctly, the figures used to be centered....
>> In general, I'm not sure that automatically selecting papersize
>> is a good idea, as it fits into the "failing silently"
>> category. I also think it falls into the "trying to be too
>> smart" category. My vote is to give them what they asked for,
>> and the means to fix problems when they arise.
> I'm going to drop autosizing in favor of passing a
> papertype kwarg to savefig. Any objections?
None from me...
> Also, I thought I could just add a papertype kwarg to
> backend_ps.FigureCanvasPS.print_figure, but that doesnt
> work. Would papertype need to be added to all the
> backend's print_figure method, or could we just add
> **kwargs (or is there something else I have overlooked)?
The problem here is that Agg and other backends will detect the ps
extensions and create a PS renderer to print the figure. See for
This has bitten me before, and in the past I was lazy and just
manually added the kwarg to each signature. This time around, I
suggest you modify the signature to be
def print_figure(self, filename, dpi=150,
Just add a catchall kwargs to each print_figure. Then in backend_agg,
elif ext.find('ps')>=0 or ext.find('ep')>=0:
from backend_ps import FigureCanvasPS # lazy import
ps = self.switch_backends(FigureCanvasPS)
ps.print_figure(filename, dpi, facecolor, edgecolor, orientation, **kwargs)
and everywhere else that print_figure is called the kwargs should be
backend_ps can then do
def print_figure(self, outfile, dpi=72,
papersize = kwargs.get('papersize', rcParams['ps.papersize'])
In this way we can support backend dependent kwargs to print w/o
having to put them in every backend (and thereby raise false
expectations). Eg, agg can just ignore the papersize kwarg and just
pass it through.
We should, however, document in the Figure.savefig command which
kwargs are available for which backends, eg
def savefig(self, *args, **kwargs):
SAVEFIG(fname, dpi=150, facecolor='w', edgecolor='w',
papersize = 'letter'|'a4'... PS backend only
So it is a fair amount of trivial/tedious work to do this right across
backends for this one minor change, but it will be worth it because it
will make it easy to extend next time around.
On Tuesday 07 March 2006 19:10, John Hunter wrote:
> Thanks, Darren
> This SF.Net email is sponsored by xPML, a groundbreaking
> scripting language that extends applications into web and
> mobile media. Attend the live webcast and join the prime
> developer group breaking into this new coding territory!
> Matplotlib-devel mailing list