PyPlotter - A Python/Jython Graph Plotting Package. Manual

Eckhart Arnold

1 Introduction
2 License
3 Screenshots
4 Quick Tutorial
5 Reference
    5.1 Overview
    5.2 Class Graph.Cartesian
    5.3 Class Simplex.Diagram
6 Implementing a new device driver for PyPlotter

5.2 Class Graph.Cartesian

Class Graph.Cartesian is versatile high level class for drawing graphs on a cartesian plain. It supports linear and logarithmic scales and automatic adjustment of the coordinate range as well as automatic captioning.

__init__
(self, gfx, x1, y1, x2, y2,
title = “Graph”, xaxis=”X”, yaxis=”Y”,
styleFlags = DEFAULT_STYLE,
axisPen = Gfx.BLACK_PEN, labelPen = Gfx.BLACK_PEN,
titlePen = Gfx.BLACK_PEN, captionPen = Gfx.BLACK_PEN,
backgroundPen = Gfx.WHITE_PEN,
region = REGION_FULLSCREEN)

Initializes the class with the following parameters:
gfx
Gfx.Driver: The Gfx drivers used for drawing the graph. Use AUTO_PEN if you want the Graph.Cartesian object to find a suitable driver (depending on the installed widget toolkits) on its own.
 
x1,y1,x2,y2
floats: Coordinate range.
 
title
string: Title string.
 
xaxis, yaxis
strings: Axis descriptions.
 
styleFlags
integer: Interpreted as a bitfield of flags that define the style of the graph. The following flags can be set:
AXISES, AXIS_DIVISION, FULL_GRID
Draw axises, axis divisions and (or) a full grid.
 
LABELS, CAPTION, TITLE
Draw axis labels, a caption with descriptions (generated from the pen names) below the graph, a title above the graph.
 
SHUFFLE_DRAW, EVADE_DRAW
Two different algorithms to allow for the visibility of overlapping graphs.
 
LOG_X, LOG_Y
Use a logarithmic scale for the x or y axis respectively.
 
KEEP_ASPECT
Keep the aspect ratio of the coordinates.
 
AUTO_ADJUST
Automatically adjust the range of the graph when a point is added that falls outside the current range.

 
axisPen, labelPen, titlePen, captionPen, backgroundPen
Gfx.Pen: Pens (sets of graphical attributes) for the respective elements of the graph.
 
region
4-tuple of floats. The part of the screen that is used for the graph. Example: (0.05, 0.05, 0.95, 0.95) would leave a border of 5 % of the screen size on each side.

 
adjustRange
(self, x1, y1, x2, y2) - Adjusts the range of the coordinate plane.
 
setStyle
(self, styleFlags=None, axisPen=None,
labelPen=None, titlePen=None, captionPen=None,
backgroundPen = None) - Changes the style of the graph. Only parameters that are not None will be changed.
 
setTitle
(self, title) - Changes the title of the graph.
 
setLabels
(self, xaxis=None, yaxis=None) - Changes the labels of the graph.
 
resizedGfx
(self) - Takes notice of a resized window.
 
changeGfx
(self, gfx) - Switch to another device context. This can be useful if you want to draw the current graph into a buffered image that you want to save on a disk. In this case you have to create the buffered image, create the Gfx driver for your buffered image, call changeGfx and then redraw. After that you can call changeGfx to switch back to the former output device.
 
redrawGraph
(self) - Redraws the graph, but not the caption, title or labels.
 
redrawCaption
(self) - Redraw only the caption of the graph.
 
redraw
(self) - Redraws the whole graph including, title, labels and the caption.
 
reset
(self, x1, y1, x2, y2) - Restarts with a new empty graph of the given range. All pens are removed.
 
addPen
(self, name, pen=AUTO_GENERATE_PEN,
updateCaption=True) - Adds a new pen with name “name” and attributes “pen” to the graph.
 
removePen
(self, name, redraw=True) - Removes a pen from the graph. All coordinate pairs associated with this pen will be discarded.
 
addValue
(self, name, x, y) - Add the point (x,y) to the graph drawn with pen “name”.
 
peek
(self, x, y) - Returns the graph coordinates of the screen coordinates (x,y)
 
xaxisSteps
(self, x1, x2) - Returns a list of virtual x-coordinates in the range [x1,x2] with one point for each screen pixel. This is especially useful when working with large range logarithmic scales.
 
yaxisSteps
(self, y1, y2) - Returns a list of virtual x-coordinates in the range [y1,y2] with one point for each screen pixel. This is especially useful when working with large range logarithmic scales.

t g+ f @