[IPython-dev] SVG figures status report

Bob McElrath bob+ipython at mcelrath.org
Wed Jun 27 15:33:09 EDT 2012

Michael Droettboom [mdroe at stsci.edu] wrote:
> I like the suggestion of "freezing/unfreezing" SVG on the fly -- that's 
> definitely worth further investigation.

On that point, I just found canvg: http://code.google.com/p/canvg/ which renders
SVG to a HTML Canvas using javascript, on the client side.  Anyone want to play
with it?

If this could be made to work, and as canvg advertises, animation even works, it
could allow a very smooth transition from Canvas to SVG for vector graphs,
when/if the browser support improves.  Or, as I suggested, "freezing/unfreezing"
too.  I wonder if simple things like coordinate reporting, if implemented in
SVG, could also work in the translated Canvas?

The advantage of Canvas is that it's a single DOM element per graph.  So
scrolling, selecting, executing cells, etc doesn't require the browser to
traverse all nodes in every SVG graph, or recalculate styles for every node.  (I
know that probably shouldn't be happening in the first place, but as far as I
can tell from Chrome's profiler, it is)

Don't forget that Matplotlib's SVG backend needs some work too.  It has
some rendering errors.  (and so does the svg output of the Cairo backend)

Cheers, Bob McElrath

"The individual has always had to struggle to keep from being overwhelmed by
the tribe.  If you try it, you will be lonely often, and sometimes frightened.
But no price is too high to pay for the privilege of owning yourself." 
    -- Friedrich Nietzsche

More information about the IPython-dev mailing list