toyplot.svg module

Generates SVG images.

toyplot.svg.apply_changes(svg, changes)[source]

Modify the SVG DOM representation of a canvas with the given changes.

toyplot.svg.render(canvas, fobj=None, animation=False)[source]

Render the SVG representation of a canvas.

Parameters:
  • canvas (toyplot.canvas.Canvas) – The canvas to be rendered.
  • fobj (file-like object or string, optional) – The file to write. Use a string filepath to write data directly to disk. If None (the default), the SVG tree will be returned to the caller instead.
  • animation (boolean, optional) – If True, return a representation of the changes to be made to the SVG tree for animation.
Returns:

  • svg (xml.etree.ElementTree.Element or None) – SVG representation of canvas, as a DOM tree, or None if the caller specifies the fobj parameter.
  • changes (JSON-compatible data structure, or None) – JSON-compatible representation of the animated changes to canvas.