You are here: home python plotsvg

The python module plotsvg

Short description

The python module plotsvg contains the class Figure() which produces an .svg file that can be rendered by svg-enabled browsers. SVG stands for "scalable vector graphics", a W3C standard for describing vector graphics elements. Most modern browsers like Firefox, Opera, Safari, Google Chrome are svg-enabled. Unfortunately, this is not the case for Microsoft's Internet Explorer. SVG graphs can easily be transformed into .png or .jpg raster images by processing a screen dump ('PrintScrn') with a graphics utility as Paint (for Windows) or the GNU Image Manipulation Program Gimp. For higher resolution than your screen size there are conversion tools on internet.

An instance of the Figure class is created by typing f=plotsvg.Figure(), after which f is defined as a Figure instance. Attributes and methods of f are then available as f.attribute or f.method(arguments).

The Figure class has several methods (for details type info(plotsvg.Figure.xxx) where xxx=method):

addobject(position,obj[,options]) Inserts svg object at given position
addtext(position, textline[,options]) Inserts line of text at given position
attributes() or attr() Prints the present values of attributes.
frame(xyrange[, options]) Defines coordinate frame with scales.
parse(s[,options]) Parses text (internal use only)
plotc(data[,options]) Plots cumulative distribution of data
plotf(function[,options]) Plots a function
plotm(M[,options]) Plots a matrix with interpolated colors
plotp(data[,options]) Plots a set of points, optional with lines and error bars
line(start,end[,options]) Draws line from start to end
show([options]) Writes the svg to a file

The module plotsvg.py defines several functions (for details type info(plotsvg.xxx) where xxx=function):

autoplotc(data[,options]) plots cumulative distribution automatically
autoplotf(function,xrange[,options]) plots a function automatically
autoplotm (M[,options]) plots a color matrix automatically
autoplotp(data[,options]) plots data points automatically
cinterpol(x,data[,options]) gives cubic interpolation of data
fminmax(function,xrange) gives min and max value of function in xrange
spline(data[,options]) cubic spline generation

Download plotsvg

plotsvg.py is a python module. It is a standard text file, not an executible, and it can therefore be downloaded on any platform on which python is installed (see here for instructions how to install python). Because the server does not allow to download files with .py extension, all xxx.py files on this website are presented as xxx.txt files that you can download. The plotsvg.txt files are extended with a prefixed date (format yymmdd) in order to distinguish versions. After downloading please change the extension back into .py and remove the date prefix before installing the file into your python system.

Install the plotsvg.py file in a place where your python program can find it: preferably in the folder Lib/site-packages/ in your python distribution. You can also install it in a folder like 'mymodules' in your workdirectory when you have extended the python path to include this folder.

download 120219plotsvg.txt

Documentation

This page contains online documentation for plotsvg. The module itself contains up-to-date documentation that can be invoked (after from plotsvg import *) by the command info:

>>>import plotsvg
>>>from plotsvg import *
>>>info(plotsvg)
>>>info(autoplotp)
>>>info(Figure.plotp)

The last 3 lines produce documentation respectively, on the module as a whole, a function in the module, a Figure method.

A complete downloadable manual in pdf format is presently in preparation.