ANN: matplotlib-0.87.1

    > 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
    > svn.
    >> 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
example

  FigureCanvasAgg.print_figure

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,
                     facecolor='w', edgecolor='w',
                     orientation='portrait', **kwargs):

Just add a catchall kwargs to each print_figure. Then in backend_agg,
for example

            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
passed through.

backend_ps can then do

    def print_figure(self, outfile, dpi=72,
                     facecolor='w', edgecolor='w',
                     orientation='portrait', **kwargs):
        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',
        orientation='portrait', **kwargs):

        ...snip...
        optional kwargs
        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.

JDH

···

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!
    > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
    > _______________________________________________
    > Matplotlib-devel mailing list
    > Matplotlib-devel@lists.sourceforge.net
    > https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Sounds fine. Why not roll dpi, facecolor, edgecolor and orientation in with
the kwargs?

···

On Thursday 09 March 2006 15:25, John Hunter wrote:

    > On Tuesday 07 March 2006 19:10, John Hunter wrote:

    > 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
    > svn.

    >> 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
example

  FigureCanvasAgg.print_figure

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,
                     facecolor='w', edgecolor='w',
                     orientation='portrait', **kwargs):

Just add a catchall kwargs to each print_figure. Then in backend_agg,
for example

            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
passed through.

backend_ps can then do

    def print_figure(self, outfile, dpi=72,
                     facecolor='w', edgecolor='w',
                     orientation='portrait', **kwargs):
        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',
        orientation='portrait', **kwargs):

        ...snip...
        optional kwargs
        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.