simpleSVG
A Python program to produce SVG graphics. Version 0.12 is new on October 6, 2008.

Last modified Tuesday, 07-Oct-2008 13:02:32 MDT
return to mensch.org

Why another plotting program?

simpleSVG translates user-friendly Python commands into an SVG graphics file. It produces only SVG graphics, and the Python is adapted to SVG. If you know a bit about SVG, such as from svgbasics.com, the Python commands will be more easily learned and effectively applied.

SVG is a vector graphics format. I confess here that when I first heard of the term "vector graphics", I thought it was referring to plots with lots of little arrows. Nope, that is not what it means! Here are some definitions of "vector graphics".

simpleSVG is intended to replace vplot, which produced postscript graphics. Like vplot, simpleSVG is intended to simplify the use of graphics primitives, to make nonstandard plots that are not available in traditional plotting programs.

Some links about SVG

Key features of simpleSVG

  1. SVG attributes such as stroke-width are written as stroke_width when used as a keyword in a argument list. simpleSVG will replace the _ with a - when writing the file.

  2. The SVG editor/viewer inkscape (excellent cross-platform free software, highly recommended as a companion to simpleSVG), seems to concatenate style attributes. Instead of stroke="blue", stroke-width="3" we see style="stroke:blue;stroke-width=3". v0.1 of simpleSVG uses the latter form, concatenated style strings. That may not have been a good idea...

  3. simpleSVG ultimately writes the files in standard SVG coordinates in "pt", with the origin in the top left, the first coordinate increasing to the right and the second coordinate increasing down. Coordinates passed as integers are assumed to be in units of "pt", long integers in units of 1/100 pt. (256 and 25600L) are the same coordinate.

  4. Coordinates passed as floats are assumed to be in "user coordinates": the conventional x and y with an origin adjacent to the lower left and bottom margins. (You may see SVG "user coordinates" defined differently in SVG documentation, here the term refers to the simpleSVG implementation.) When simpleSVG writes to a file, user coordinates are converted to SVG coordinates, according to the linear transformation defined by the user.

Installing simpleSVG

Here it is: Installing simpleSVG.py can be as simple as keeping a copy in the same directory as the Python programs that will import it. Or keep it in a directory accesible by your PYTHONPATH.

Using simpleSVG