[IPython-dev] [QUAR] Re: Qt SVG clipping bug (it's NOT a matplotlib bug)- Qt won't fix...

John Hunter jdh2358@gmail....
Thu Oct 14 12:05:06 CDT 2010


On Thu, Oct 14, 2010 at 11:58 AM, Mark Voorhies <mark.voorhies@ucsf.edu> wrote:

> * Saving as PNG via Matplotlib's GUI as launched from iPython
>  gives a correctly clipped PNG.  I'm not sure if Matplotlib is
>  rasterizing directly, or drawing to the GUI canvas and then
>  asking the GUI to generate a PNG.  Also, not sure which
>  GUI backend I'm looking at...

matplotlib can mix and match GUI frontends with renderers, eg we do
support native GTK or WX rendering into their respective canvases.
But we recommend for most people to use one of the *Agg backends
(GTKAgg, TkAgg, WXAgg, QtAgg, etc) in which case we will render the
graphics using Agg (antigrain) and then dump them into the GUI canvas
as a pixel buffer.  So if you ask for a PNG from any of the *Agg
backends, you will get a matplotlib rendered PNG.  For more details
see

http://matplotlib.sourceforge.net/faq/installing_faq.html#backends

> Would it be reasonable to bypass the Qt issue by asking Matplotlib
> for a PNG at the time that we receive the SVG and put that on
> our console canvas?  It seems like this would be a good general
> strategy for supporting non-Qt frontends (e.g., James Gao might
> want something like this for the HTML frontend to support older
> browsers).

It should be fairly trivial to get mpl to generate a PNG on the kernel
side by requesting backend Agg, and then shipping that along with your
SVG and embedding it into your widget.

JDH


More information about the IPython-dev mailing list