[IPython-dev] [QUAR] Re: Qt SVG clipping bug (it's NOT a matplotlib bug)- Qt won't fix...
Brian Granger
ellisonbg at gmail.com
Thu Oct 14 13:02:27 EDT 2010
Mark,
I like the idea of getting the .PNG rather than the .SVG, but can we
still embed it in the html output?
Cheers,
Brian
On Thu, Oct 14, 2010 at 9:58 AM, Mark Voorhies <mark.voorhies at ucsf.edu> wrote:
> On Thursday, October 14, 2010 08:27:10 am Michael Droettboom wrote:
>> On 10/14/2010 10:52 AM, Robert Kern wrote:
>> > On 10/14/10 3:55 AM, Hans Meine wrote:
>> > It might be worthwhile for matplotlib to only use the SVG 1.2 Tiny standard for
>> > greater compatibility. Tiny is much easier to implement, so I suspect there are
>> > now more Tiny renderers now than there are Full renderers.
>> >
>> This is true -- and we can probably remove some of the simpler-to-remove
>> parts that are missing from SVG Tiny. However, to support clipping, we
>> either have to either a) write the routines to do clipping in vector
>> space or b) use rasterized fallbacks (as we do for some alpha issues in
>> Postscript, for instance). a) is non-trivial in the general case,
>> particularly when accounting for line thicknesses, and b) is a hack.
>
> Just to clarify what's happening on the iPython Qt console side:
>
> * We receive SVG (with clipping path) from Matplotlib
>
> * We wrap the SVG in Qt's rasterizer
> (via rich_ipython_widget._process_execute_payload
> calling svg.svg_to_image) and drop that as a widget on the
> console canvas.
>
> + As noted, the Qt rasterizer doesn't implement clipping, so
> we get unclipped plots drawn on the console.
>
> + This strategy also results in rasterized plots in the PDF export.
>
> * For the context menu "Save Image As" and "Export HTML"
> functions, we call save(filename, "PNG") on the Qt
> rasterizer, so we get the same lack-of-clipping artifact.
>
> * For the context menu "Save SVG As" and "Export XHTML"
> we work from Matplotlib's original SVG, so the clipping path
> is retained (and we get correct clipping in Inkscape, Firefox,
> and WebKit).
>
> * 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...
>
> 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).
>
> --Mark
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
--
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com
More information about the IPython-dev
mailing list