.
Class canvas
Use this to make a drawing surface of type eps, pdf, or svg (for now). Most simple plots use a single canvas and one or more drawables to get their work done.
Initialize with following parameters:
canvas_type | | default: 'eps' | | Canvas type: Can be eps, pdf, svg (for now). |
| | | | |
title | | default: 'default' | | Base name of the output file. Output will be |
| | | | of the form: 'title.canvas_type' |
dimensions | | default: ['3in','2in'] | | Size of the drawing surface. |
default_font | | default: 'Helvetica' | | Default font for text. |
verbose | | default: False | | Whether to add more info into output file. |
| | | | |
script | | default: __file__ | | Name of the file calling into zplot; recorded in header. |
| | | | |
canvas.text()
Use this routine to place text on the canvas. Most options are obvious: the expected coordinate pair, color, text, font, size - the size of the font, rotation - which way the text should be rotated, but the anchor can be a bit confusing. Basically, the anchor determines where, relative to the coordinate pair (x,y), the text should be placed. Simple anchoring includes left (l), center (c), or right (r), which determines whether the text starts at the x position specified (left), ends at x (right), or is centered on the x (center). Adding a second anchor (xanchor,yanchor) specifies a y position anchoring as well. The three options there are low (l), which is the default if none is specified, high (h), and middle (m), again all determining the placement of the text relative to the y coordinate specified.
coord | | default: [0,0] | | Coordinates for text on the canvas. |
text | | default: 'text' | | Actual text to place on the canvas. |
font | | default: 'default' | | Typeface to use. |
color | | default: 'black' | | Color of letters. |
size | | default: 10 | | Font size. |
rotate | | default: 0 | | Rotate text by this many degrees. |
anchor | | default: 'c' | | Anchor: can either just specify left/right |
| | | | (e.g., 'c' for center, 'l' for left justify, 'r' for right) |
| | | | or can also specify vertical alignment (e.g., 'l,h' for left justify and high justify, |
| | | | 'r,c' for right and center, 'l,l' for left and low). |
| | | | |
bgcolor | | default: '' | | Background color behind text? Empty means no. |
| | | | |
bgborder | | default: 1 | | Border (black) around background color? |
canvas.line()
Use this to draw a line on the canvas.
coord | | default: [[0,0],[0,0]] | | Coordinates of the line. A list of [x,y] pairs. Can |
| | | | be as long as you like (not just two points). |
| | | | |
linecolor | | default: 'black' | | Color of the line. |
linewidth | | default: 1 | | Width of the line. |
linejoin | | default: 0 | | For turns in the line, how turn should be rounded. |
| | | | Options include 0->'miter', 1->'round', 2->'bevel'. |
| | | | Default is just do hard turns (miter). |
linecap | | default: 0 | | Shape used at end of line (0->'butt', 1->'round', 2->'square') |
| | | | |
linedash | | default: 0 | | Dash pattern of the line. '0' means no dashes. |
| | | | Otherwise, a list describing the on/off pattern |
| | | | of the dashes, e.g., [2,2] means 2 on, 2 off, repeating. |
| | | | |
closepath | | default: False | | Can use this to close the path (and perhaps fill it). |
| | | | However, not really supported right now. |
arrow | | default: False | | Turn an arrow at last segment on or off. |
arrowheadlength | | default: 4 | | Length of arrow head. |
arrowheadwidth | | default: 3 | | Width of arrow head. |
arrowlinecolor | | default: 'black' | | Color of arrow head line. |
arrowlinewidth | | default: 0.5 | | Width of line that makes arrow head. |
arrowfill | | default: True | | Fill arrow head with solid color? |
arrowfillcolor | | default: 'black' | | Color to fill arrow head with. |
arrowstyle | | default: 'normal' | | Style to use. 'normal' is one option. There are no others. |
| | | | |
canvas.box()
Makes a box at coords specifying the bottom-left and upper-right corners. Can change the width of the surrounding line (linewidth=0 removes it). Can fill with solid or pattern. When filling with non-solid pattern, can add a background color so as not to be see-through.
coord | | default: [[0,0],[0,0]] | | Coordinates of box, from [x1,y1] to [x2,y2]. |
| | | | |
linecolor | | default: 'black' | | Color of lines that draws box. |
linewidth | | default: 1 | | Width of those lines. 0 means unlined box. |
| | | | |
linedash | | default: 0 | | Dash pattern in lines around box? |
linecap | | default: 0 | | How should corners be done? 0 is default; 1->'round', 2->'bevel'. |
| | | | |
linejoin | | default: 0 | | For turns in the line, how turn should be rounded. |
| | | | Options include 0->'miter', 1->'round', 2->'bevel'. |
| | | | Default is just do hard turns (miter). |
fill | | default: False | | Should box be filled? If so, specify here. |
| | | | |
fillcolor | | default: 'black' | | Color of the fill pattern. |
fillstyle | | default: 'solid' | | Type of fill pattern. Right now, all are 'solid'. |
| | | | |
fillsize | | default: 3 | | Details of fill pattern includes size of each marker in pattern. |
| | | | |
fillskip | | default: 4 | | Also includes spacing between each marker in pattern. |
| | | | |
rotate | | default: 0 | | Rotate the box by this many degrees. |
bgcolor | | default: '' | | Put a background color behind the box. Useful when pattern has |
| | | | see-through parts in it. |
canvas.circle()
Can just make circles with this. Can fill them too. Exciting!
coord | | default: [0,0] | | Coordinates of center of circle in [x,y]. |
| | | | |
radius | | default: 1 | | Radius of circle. |
scale | | default: [1,1] | | Scale in x direction and y direction, to make |
| | | | an ellipse, for example. |
linecolor | | default: 'black' | | Color of lines of circle. |
linewidth | | default: 1 | | Width of lines of circle. |
linedash | | default: 0 | | Whether line is dashed or not. |
fill | | default: False | | Fill circle with colored pattern? |
fillcolor | | default: 'black' | | Which color? |
fillstyle | | default: 'solid' | | Which pattern? |
fillsize | | default: 3 | | Details of pattern: size of each marker. |
fillskip | | default: 4 | | Details of pattern: space between each marker. |
| | | | |
bgcolor | | default: '' | | Background color behind circle, useful if fill pattern |
| | | | has some holes in it. |
canvas.polygon()
Use this method to make an arbitrary polygon, by passing in its coordinates. All the usual arguments are specified.
coord | | default: [] | | The list of [x,y] pairs that form the coordinates. |
| | | | |
linecolor | | default: 'black' | | The color of the surrounding line (if width > 0). |
| | | | |
linewidth | | default: 1 | | The width of the line (0 for no line). |
linecap | | default: 0 | | The linecap. |
linejoin | | default: 0 | | The linejoin. |
linedash | | default: 0 | | The line dash pattern. |
fill | | default: False | | Fill the polygon? |
fillcolor | | default: 'black' | | What color to fill it? |
fillstyle | | default: 'solid' | | What style to fill it with? |
fillsize | | default: 3 | | The fill size... |
fillskip | | default: 4 | | ...and the skip. |
bgcolor | | default: '' | | A background color if there is no fill; useful |
| | | | behind a pattern. |
.
Class drawable
Creates a drawable region onto which graphs can be drawn. Must define the xrange and yrange, which are each min,max pairs, so that the drawable can translate data in table into points on the graph. Also, must select which type of scale each axis is, e.g., linear, log10, and so forth. If unspecified, coordinates (the x,y location of the lower left of the drawable) and dimensions (the width, height of the drawable) will be guessed at; specifying these allows control over where and how big the drawable is. Other options do things like place a background color behind the entire drawable or make an outline around it.
Initialize with following parameters:
canvas | | default: '' | | Canvas object upon which to draw. |
dimensions | | default: [] | | Dimensions of the drawable surface; e.g., ['1in','1in']. |
| | | | If left as empty list, will make a guess as to size. |
| | | | |
coord | | default: [] | | Lower-left corner of drawable should be placed at this |
| | | | location on the canvas. If left as empty, will make a guess. |
| | | | |
xrange | | default: [] | | X range of the drawable. |
yrange | | default: [] | | Y range of the drawable |
xscale | | default: 'linear' | | Scale to use ('linear' or 'log2' or 'log10' or 'logX') |
| | | | for x range; currently, no other types of scales supported. |
| | | | |
yscale | | default: 'linear' | | Scale to use ('linear' or 'log2' or 'log10' or 'logX') |
| | | | for y range; currently, no other types of scales supported. |
| | | | |
drawable.map()
Can be used to map coordinates from something a drawable understands to something that can be used on the canvas directly. Useful when placing text or shapes on the canvas directly; pass d.map([x,y]) for example to the coord= argument of a canvas direct draw function (such as text, line).
coord | | default: ['',''] | | The coordinates to translate from the drawable coordinate system |
| | | | to the canvas raw coordinates. Coordinates can be a single list |
| | | | [x,y] or, for e.g. a line, a list of points [[x1,y1],[x2,y2]]. |
| | | | |
.
Class table
Tables store data to be plotted, and provide a thin layer over SQLite to select subsets of the data to plot. A table can be created and filled with contents of a file (the 'file' parameter) OR created and filled with data from another table (the 'table' parameter). When filling with data from a file, it is useful to pass in a 'separator' which tells the table class how the rows in the file are split. Default is whitespace.
Initialize with following parameters:
file | | default: '' | | File name where table should be populated from; |
| | | | file should have fixed number of columns of data. |
| | | | |
table | | default: '' | | If file name is not specified (as above), can populate |
| | | | a table with data from another table (this makes a copy). |
| | | | |
where | | default: '' | | When initializing a table from another table, use the |
| | | | 'where' option to perform a selection of which data you want. |
| | | | For example, 'where=c0 > 10' populates the new table with |
| | | | all rows where the first value in the row (i.e., c0) is |
| | | | greater than 10. |
separator | | default: '' | | When reading from a file, use the 'separator' to split each |
| | | | line and thus decide the different entries for that line. |
| | | | Default is to use whitespace; a colon is a common one too. |
| | | | |
table.getaxislabels()
This method takes a column of data and returns it in a form so you can directly pass it to the axis() class as either the 'xmanual' or 'ymanual' parameter. Thus, you can call axis as follows: axis(xmanual=t.getaxislabels('c0'), ...) to get the values from column 'c0' of table 't' and use it to label the x axis (in this example).
column | | default: '' | | Which column to grab the data from. |
table.dump()
Used to dump the contents of the table to stdout.
title | | default: '' | | A title to add to the output for clarity. |
| | | | |
canvas | | default: None | | Can add this to the output as well as a comment. |
| | | | |
table.insert()
Allows SQL insert directly into a table. SET column1=value, column2=value2,... WHERE some_column=some_value Format of keyValues should be ... XXX
keyValues | | default: {} | | Needs a better description. |
table.update()
Enables an update() of values in a column. Can use to sum two columns, for example.
set | | default: '' | | Specify how to set values in one column. Can just set a column |
| | | | to a specific value (e.g., set='c0 = 100') or can do math |
| | | | across some columns (e.g., set='c0 = c0 + c1'). |
| | | | |
where | | default: '' | | Can operate on a subset of rows via selection. |
| | | | |
table.getmax()
Utility function to get maximum value of a particular column.
column | | default: '' | | column to compute max over. |
cmax | | default: '' | | If specified, only return value from column if it's |
| | | | greater than 'cmax'. Otherwise, just return max. |
| | | | |
table.getmin()
Returns min value over a given column.
column | | default: '' | | Column to get data from. |
cmin | | default: '' | | Only return values if they are less than cmin. |
| | | | If not specified, just return min found. |
table.getrange()
Gets the [min, max] of a column and returns it as a list.
column | | default: '' | | The column to perform min, max over. |
crange | | default: '' | | If not empty, 2-element list with min value |
| | | | and max value not to go below/exceed when looking |
| | | | for min and max in the column. |
table.getvalues()
Returns values in a column as a list.
column | | default: '' | | Column to get values of. |
table.getavg()
Compute average over a column and return it.
column | | default: '' | | Column over which to compute average. |
where | | default: '' | | Where clause used to select subset of rows. |
| | | | |
table.query()
Get data from table via a query.
where | | default: '' | | Where clause to select which data to return. |
| | | | |
order | | default: '' | | Which column to order the results by; '' -> don't order. |
| | | | |
select | | default: '*' | | * selects all columns, or you can pick a subset. |
| | | | |
group | | default: '' | | The group by clause also useful sometimes. |
| | | | |
table.addcolumns()
Add a bunch of columns all at once.
columns | | default: [] | | columns to add to the table, all at once |
table.addcolumn()
Add a column to the table, and initialize it with value.
column | | default: '' | | Column to be added. |
value | | default: '' | | Value to initialize column to. |
.
Class plotter
Use this to draw some points on a drawable. There are some obvious parameters: which drawable, which table, which x and y columns from the table to use, the color of the point, its linewidth, and the size of the marker. 'style' is a more interesting parameter, allowing one to pick a box, circle, horizontal line (hline), and 'x' that marks the spot, and so forth. However, if you set 'style' to label, PlotPoints will instead use a column from the table (as specified by the 'label' flag) to plot an arbitrary label at each (x,y) point. Virtually all the rest of the flags pertain to these text labels: whether to rotate them, how to anchor them, how to place them, font, size, and color.
Initialize with following parameters:
drawable | | default: '' | | The default drawable for this plotter. However, you can |
| | | | specify a different drawable when making specific graphs |
| | | | (which thus overrides this default). |
plotter.points()
Use this to draw points, as specified by x,y of a table, onto a drawable. Basically, how you make a scatter plot is with the points() method.
drawable | | default: '' | | Drawable object to place points onto. |
table | | default: '' | | Table object to suck data from. |
where | | default: '' | | Where clause: which rows to plot? Default is all rows. |
| | | | |
xfield | | default: 'c0' | | Table column with x data. |
yfield | | default: 'c1' | | Table column with y data. |
shift | | default: [0,0] | | Shift points in x,y direction by this amount. |
| | | | |
size | | default: 2.0 | | Size of each point; used unless sizefield is specified. |
| | | | |
style | | default: 'xline' | | Lots of styles available for these points, including: |
| | | | label, hline, vline, plusline, xline, dline1, dline2, dline12, |
| | | | square, circle, triangle, utriangle, diamond, star, asterisk. |
| | | | |
sizefield | | default: '' | | If specified, table column with sizes for each point. |
| | | | Allows point size to vary which is a nice feature. |
| | | | |
sizediv | | default: '' | | If using sizefield, use sizediv to scale each value (each |
| | | | sizefield gets divided by sizediv to get to the final size). |
| | | | |
linecolor | | default: 'black' | | Color of the line of the marker. |
linewidth | | default: 1.0 | | Width of lines used to draw marker. |
fill | | default: False | | For some shapes, filling makes sense; if desired, mark True. |
| | | | |
fillcolor | | default: 'black' | | If filling, use this fill color. |
fillstyle | | default: 'solid' | | If filling, which fill style: solid, hline, vline, hvline, |
| | | | dline1, dline2, dline12, circle, square, triangle, utriangle. |
| | | | |
fillsize | | default: 3.0 | | Size of object in pattern. |
fillskip | | default: 4.0 | | Space between object in pattern. |
labelfield | | default: '' | | If specified, table column with labels for each point. |
| | | | |
labelformat | | default: '%s' | | If specified, table column with labels for each point. |
| | | | |
labelrotate | | default: 0 | | If using labels, rotate labels by this many degrees. |
| | | | |
labelanchor | | default: 'c,c' | | If using labels, how to anchor them. 'x,y' where x can be |
| | | | 'c' or 'l' or 'r' (for center, left, right) and y can be |
| | | | 'c' or 'h' or 'l' for center, high, low). |
| | | | |
labelplace | | default: 'c' | | If using labels, place text: 'c' centered on point, |
| | | | 's' below [south], 'n' above [north], 'e' east, 'w' west. |
| | | | |
labelshift | | default: [0,0] | | Shift text in label x,y direction |
labelfont | | default: 'default' | | If using labels, what font. |
labelsize | | default: 6.0 | | If using labels, fontsize for label. |
labelcolor | | default: 'black' | | If using labels, what color font. |
labelbgcolor | | default: '' | | If using labels, put a background color behind each. |
| | | | |
legend | | default: '' | | Which legend object to use to add legend text to. |
| | | | |
legendtext | | default: '' | | Text to add to legend. |
stackfields | | default: [] | | Fields to add to yfield to determine y coord. |
| | | | Can use this instead of table methods. |
plotter.horizontalbars()
Use this to plot horizontal bars. The options are quite similar to the vertical cousin of this routine, except (somehow) less feature-filled (hint: lazy programmer).
drawable | | default: '' | | Drawable object on which to put the bars. |
| | | | |
table | | default: '' | | Table from which to draw data. |
where | | default: '' | | SQL select to subset the data as need be. |
| | | | |
xfield | | default: 'c0' | | Table column with x values. |
yfield | | default: 'c1' | | Table column with y values. |
xloval | | default: '' | | If specified, table column with xlo data; use if bars |
| | | | don't start at the minimum of the range. |
barwidth | | default: 1.0 | | Width of the bars. |
linecolor | | default: 'black' | | Color of the lines. |
linewidth | | default: 1.0 | | Width of the lines. 0 means no lines at all! |
| | | | |
fill | | default: False | | Whether to fill each bar with some pattern. |
| | | | |
fillcolor | | default: 'black' | | Fill color for bars (if fill=True). |
fillstyle | | default: 'solid' | | Fill style for bars (if fill=True). |
fillsize | | default: 3 | | Fill size (if pattern has a marker of some size in it). |
| | | | |
fillskip | | default: 4 | | Fill space between markers (if pattern has marker). |
| | | | |
bgcolor | | default: '' | | Background color for bar - can make sense if pattern |
| | | | contains little markers, for example, because you can |
| | | | use this to fill in a background color then. |
| | | | |
legend | | default: '' | | Legend object (if using a legend). |
legendtext | | default: '' | | Text for legend. |
stackfields | | default: [] | | Fields to add to yfield to determine y coord. |
| | | | |
plotter.verticalbars()
Use this to plot vertical bars on a drawable. A basic plot will specify the table, xfield, and yfield. Bars will be drawn from the minimum of the range to the y value found in the table. If the bars should start at some value other than the minimum of the range (for example, when the yaxis extends below zero, or you are building a stacked bar chart), two options are available: ylofield and yloval. ylofield specifies a column of a table that has the low values for each bar, i.e., a bar will be drawn at the value specifed by the xfield starting at the ylofield value and going up to the yfield value. yloval can be used instead when there is just a single low value to draw all bars down to. Some other interesting options: labelfield, which lets you add a label to each bar by giving a column of labels (use rotate, anchor, place, font, fontsize, and fontcolor flags to control details of the labels); barwidth, which determines how wide each bar is in the units of the x-axis; linecolor, which determines the color of the line surrounding the box, and linewidth, which determines its thickness (or 0 to not have one); and of course the color and fill of the bar, as determined by fillcolor, fillstyle, and fillsize and fillskip.
drawable | | default: '' | | drawable to place vertical bars upon. |
table | | default: '' | | table to get data from. |
where | | default: '' | | SQL clause to subset some of the data |
xfield | | default: 'c0' | | xfield to use |
yfield | | default: 'c1' | | yfield to use |
ylofield | | default: '' | | if specified, table column with ylo data; use if bars |
| | | | don't start at the minimum of the range |
stackfields | | default: [] | | fields to add to yfield to determine y coord |
| | | | |
yloval | | default: '' | | if there is no ylofield, use this value to fill down to; |
| | | | if empty, just use min of yrange |
barwidth | | default: 1.0 | | |
cluster | | default: [0,1] | | of the form n,m; thus, each x-axis data point actually |
| | | | will have 'm' bars plotted upon it; 'n' specifies which |
| | | | cluster of the 'm' this one is (from 0 to m-1); width of |
| | | | each bar is 'barwidth/m'; normal bar plots (without |
| | | | clusters) are just the default, '0,1' |
linecolor | | default: 'black' | | color of the line surrounding each bar |
linewidth | | default: 0.25 | | width of the line; set to 0 if you don't want a |
| | | | surrounding line on the box |
fill | | default: False | | fill the box or not |
fillcolor | | default: 'gray' | | fill color (if used) |
fillstyle | | default: 'solid' | | solid, boxes, circles, ... |
fillsize | | default: 3 | | size of object in pattern |
fillskip | | default: 4 | | space between object in pattern |
bgcolor | | default: '' | | color background for the bar; empty means none (patterns |
| | | | may be see through) |
labelfield | | default: '' | | if specified, table column with labels for each bar |
| | | | |
labelformat | | default: '%s' | | use this format for the labels; can prepend and postpend |
| | | | arbitrary text |
labelrotate | | default: 0 | | rotate labels by this many degrees |
labelanchor | | default: '' | | text anchor if using a labelfield; empty means use a |
| | | | best guess |
labelplace | | default: 'o' | | place label (o) outside of bar or (i) inside of bar |
| | | | |
labelshift | | default: [0.0,0.0] | | shift text in x,y direction |
labelfont | | default: 'default' | | if using labels, what font should be used |
| | | | |
labelsize | | default: 10.0 | | if using labels, font for label |
labelcolor | | default: 'black' | | if using labels, what color font should be used |
| | | | |
labelbgcolor | | default: '' | | if specified, fill this color in behind each text item |
| | | | |
legend | | default: '' | | which legend? |
legendtext | | default: '' | | text to add to legend |
plotter.line()
Use this function to plot lines. It is one of the simplest routines there is -- basically, it takes the x and y fields and plots a line thru them. It does NOT sort them, though, so you might need to do that first if you want the line to look pretty. The usual line arguments can be used, including color, width, and dash pattern.
drawable | | default: '' | | Drawable object to place points onto. |
table | | default: '' | | Table object to suck data from. |
where | | default: '' | | Where clause: which rows to plot? Default is all rows. |
| | | | |
xfield | | default: 'c0' | | Table column with x data. |
yfield | | default: 'c1' | | Table column with y data. |
stairstep | | default: False | | plot the data in a stairstep manner (e.g., CDF) if this is True |
| | | | |
linecolor | | default: 'black' | | color of line. |
linewidth | | default: 1.0 | | width of line. |
linejoin | | default: 0 | | specifies "linejoin". Options include 0->'miter', 1->'round', 2->'bevel' |
| | | | Default is miter |
linecap | | default: 0 | | Shape used at end of line (0->'butt', 1->'round', 2->'square') |
| | | | |
linedash | | default: 0 | | dash pattern - 0 means no dashes. [2,2] means line of 2, space of 2 |
| | | | |
labelfield | | default: '' | | if specified, table column with labels for each point in line. |
| | | | Rest of label args spec things about the lables. |
| | | | |
labelplace | | default: 'n' | | which direction from point to place label. n->north, etc. |
| | | | |
labelfont | | default: 'default' | | which font to use |
labelsize | | default: 8.0 | | size of text for labels. |
labelcolor | | default: 'black' | | color of label text. |
labelanchor | | default: 'c' | | how to anchor the text relative to the point. |
| | | | |
labelrotate | | default: 0 | | angle (degrees) to rotate text. |
labelshift | | default: [0,0] | | shift the labels by [x,y] |
labelformat | | default: '%s' | | format string to use for labels |
labelbgcolor | | default: '' | | put a box of color behind each label |
labeloffset | | default: 3.0 | | if using labels, how much to offset from point by |
| | | | |
legend | | default: '' | | legend object to use for this; '' means none. |
| | | | |
legendtext | | default: '' | | text to associate with this specific line in legend. |
| | | | |
symbstyle | | default: '' | | if adding points as well - a convenience? |
| | | | |
symbsize | | default: 2 | | |
symbfill | | default: False | | |
plotter.function()
Use function() to plot a function right onto a drawable. The function should simply take one argument (e.g., x) and return the value of the function (e.g., f(x)).
drawable | | default: '' | | drawable to place function upon. |
function | | default: '' | | the function, such as 'x*x' or 'x' or '3*x + 10', etc. |
| | | | |
xrange | | default: [0,10] | | the x-range the function should be plotted over [xmin,xmax] |
| | | | |
step | | default: 1 | | given the range of xmin to xmax, step determines at which x |
| | | | values the function is evaluated and a line is drawn to |
| | | | |
ylimit | | default: ['',''] | | if given, limit function to values between low/hi y values |
| | | | |
linewidth | | default: 1 | | line width |
linecolor | | default: 'black' | | line color |
linedash | | default: 0 | | dash pattern; 0 for none. |
legend | | default: '' | | legend object |
legendtext | | default: '' | | text to associate with this line. |
plotter.horizontalintervals()
Use this to plot interval markers in the x direction. The y column has the y value for each interval, and draws the interval between the ylo and yhi column values. The marker can take on many forms, as specified by the 'align' flag. Note the 'b' type in particular, which can be used to assemble box plots.
drawable | | default: '' | | drawable object |
table | | default: '' | | table object with data |
where | | default: '' | | select a subset of the table? |
yfield | | default: '' | | table column with y data |
xlofield | | default: '' | | table column with xlo data |
xhifield | | default: '' | | table column with xhi data |
align | | default: 'c' | | c-center u-upper l-lower n-none |
linecolor | | default: 'black' | | color of the line |
linewidth | | default: 1 | | width of all lines |
devwidth | | default: 3 | | width of interval marker on top |
plotter.verticalintervals()
Use this to plot interval markers in the y direction. The x column has the x value for each interval, and draws the interval between the ylo and yhi column values. The marker can take on many forms, as specified by the 'align' flag. Note the 'b' type in particular, which can be used to assemble box plots.
drawable | | default: '' | | |
table | | default: '' | | |
where | | default: '' | | |
xfield | | default: 'c0' | | |
ylofield | | default: 'c1' | | |
yhifield | | default: 'c2' | | |
align | | default: 'c' | | |
linecolor | | default: 'black' | | |
linewidth | | default: 1 | | |
devwidth | | default: 3 | | |
plotter.verticalfill()
Use this function to fill a vertical region between either the values in yfield and the minimum of the y-range (default), the yfield values and the values in the ylofield, or the yfield values and a single yloval. Any pattern and color combination can be used to fill the filled space.
drawable | | default: '' | | the drawable object |
table | | default: '' | | table object |
where | | default: '' | | where clause to select subset of data if need be |
| | | | |
xfield | | default: '' | | table column with x data |
yfield | | default: '' | | table column with y data |
ylofield | | default: '' | | if not empty, fill down to this column value |
| | | | |
yloval | | default: '' | | if no ylofield, use this value to fill down to; |
| | | | if empty, use min of y-range |
stairstep | | default: False | | use stairsteps in making fill |
fillcolor | | default: 'lightgrey' | | fill color (if used) |
fillstyle | | default: 'solid' | | solid, boxes, circles, ... |
fillsize | | default: 3 | | size of object in pattern |
fillskip | | default: 4 | | space between object in pattern |
legend | | default: '' | | which legend object? |
legendtext | | default: '' | | text to add to legend |
plotter.heat()
Use this to plot a heat map. A heat map takes x,y,heat triples and plots a gray-shaded box with darkness proportional to (heat/divisor) and of size (width by height) at each (x,y) coordinate.
drawable | | default: '' | | drawable object |
table | | default: '' | | name of table to use |
where | | default: '' | | subset of table via query? |
xfield | | default: 'c0' | | table column with x data |
yfield | | default: 'c1' | | table column with y data |
hfield | | default: 'heat' | | table column with heat data |
width | | default: 1 | | width of each rectangle |
height | | default: 1 | | height of each rectangle |
divisor | | default: 1.0 | | how much to divide heat value by |
label | | default: False | | if true, add labels to each heat region reflecting count value |
| | | | |
labelfont | | default: 'default' | | if using labels, what font should be used |
| | | | |
labelcolor | | default: 'orange' | | if using labels, what color is the font |
labelsize | | default: 6.0 | | if using labels, what font size should be used |
| | | | |
labelformat | | default: '%.2f' | | if using labels, what should the format be |
| | | | |
.
Class axis
Use this to draw some axes. There are a huge number of options. A first decision might be which 'style' to use: 'x' (x axis only), 'y' (y axis), 'xy' (for x and y axes), and 'box' to put a box around the entire thing. Making multiple axes is nice if you have, for example, two y axes for different data sets plotting onto the same drawable.
Initialize with following parameters:
drawable | | default: '' | | The drawable object upon which to draw this axis. |
| | | | |
linecolor | | default: 'black' | | The color of axis line. |
linewidth | | default: 1.0 | | The width of axis line. |
linedash | | default: 0 | | dash parameters; will make axes dashed, but not tic marks. |
| | | | 0 means no dashes; otherwise use a list to specify the |
| | | | dash pattern (e.g., [2,2], or [2,3,2], etc.). |
| | | | |
style | | default: 'xy' | | Which axes to draw: 'xy', 'x', 'y', 'box' are the options. |
| | | | |
labelstyle | | default: 'out' | | Labels 'in' or 'out'? for xaxis, 'out' means below and |
| | | | 'in' above; for yaxis,'out' means left/'in' right |
| | | | |
ticstyle | | default: 'out' | | Are tics 'in', 'out', or 'centered'? (inside the axes, |
| | | | outside them, or centered upon the axes) |
doaxis | | default: True | | Whether to draw the actual axes or not; useful if you just |
| | | | want to draw the tic marks, for example. |
dolabels | | default: True | | Whether to put labels on or not. |
domajortics | | default: True | | Whether to put majortics on axes or not. |
doxmajortics | | default: True | | Whether to put major tics on x-axis. |
doymajortics | | default: True | | Whether to put major tics on y-axis. |
dominortics | | default: False | | Whether to put minortics on axes or not. |
doxminortics | | default: True | | Whether to put major tics on x-axis. |
doyminortics | | default: True | | Whether to put major tics on y-axis. |
doxlabels | | default: True | | Whether to put labels on x-axis. |
doylabels | | default: True | | Whether to put labels on y-axis. |
xaxisrange | | default: '' | | The min/max values to draw xaxis between; empty (default) |
| | | | means the whole range. |
yaxisrange | | default: '' | | The min/max values to draw yaxis between; empty (default) |
| | | | means the whole range. |
xaxisposition | | default: '' | | The y value that the x-axis is located at; empty gives you |
| | | | the min; ignored by 'box'. |
yaxisposition | | default: '' | | The x value that the y-axis is located at; empty gives you |
| | | | the min; ignored by 'box'. |
xauto | | default: ['','',''] | | [x1,x2,step] will put labels and major tics from 'x1' to 'x2' |
| | | | with 'step' between each; can leave any of these empty ('') |
| | | | and the method will fill in a guess (either the min or max |
| | | | of range, or a guess for the step), e.g., [0,'',2] means |
| | | | start at 0, fill in the max of the xrange for a max value, |
| | | | and set the step to 2. The default is to guess these values. |
| | | | |
xmanual | | default: '' | | Specify labels/majortics by hand with a list of form: |
| | | | [['label1', x1], ['label2', x2]...]. Can also be filled in |
| | | | from a table column with method table.getaxislabels(column=). |
| | | | |
yauto | | default: ['','',''] | | Similar to xauto, but for the y-axis. |
ymanual | | default: '' | | Similar to xmanual, but for y-axis. |
ticmajorsize | | default: 4.0 | | Size of the major tics. |
ticminorsize | | default: 2.5 | | Size of the minor tics. |
xminorticcnt | | default: 1 | | how many minor tics between each major tic (x axis) |
| | | | |
yminorticcnt | | default: 1 | | how many minor tics between each major tic (y axis) |
| | | | |
xlabelfont | | default: 'default' | | Font to use for x labels. |
xlabelfontsize | | default: 10.0 | | font size of labels for x labels. |
xlabelfontcolor | | default: 'black' | | font color for x labels. |
xlabelrotate | | default: 0 | | Rotation for x labels, in degrees. If not 0, 90 is common. |
| | | | |
xlabelbgcolor | | default: '' | | If non-empty, put a background colored square behind xlabels. |
| | | | |
xlabelanchor | | default: '' | | Text anchor for labels along the x axis; empty means guess. |
| | | | |
xlabelformat | | default: '' | | Format string for xlabels; e.g., %d for ints; empty (default) |
| | | | implies best guess; can also use this to add decoration to |
| | | | the label, e.g., '%i %%' will add a percent sign to each |
| | | | integer label, and so forth. |
ylabelfont | | default: 'default' | | Font to use for y labels. |
ylabelfontsize | | default: 10.0 | | font size of labels for y labels. |
ylabelfontcolor | | default: 'black' | | font color for y labels. |
ylabelrotate | | default: 0 | | Rotation for x labels, in degrees. If not 0, 90 is common. |
| | | | |
ylabelbgcolor | | default: '' | | If non-empty, put a background colored square behind ylabels. |
| | | | |
ylabelanchor | | default: '' | | Text anchor for labels along the x axis; empty means guess. |
| | | | |
ylabelformat | | default: '' | | Format string for y labels; see xlabelformat for details. |
| | | | |
xlabeltimes | | default: 1 | | What to multiply xlabel values by; e.g., if 10, 1 becomes 10, |
| | | | 2 becomes 20, and so forth. |
ylabeltimes | | default: 1 | | Similar to xlabeltimes, but for y label values. |
| | | | |
xlabelshift | | default: [0,0] | | Shift xlabels left/right, up/down (+4,-3 -> right 4, down 3) |
| | | | |
ylabelshift | | default: [0,0] | | Similar to xshift, but for ylabels. |
xtitle | | default: '' | | Title along the X axis. |
xtitlefont | | default: 'default' | | Font to use for x title. |
xtitlesize | | default: 10 | | Font size for x title. |
xtitlecolor | | default: 'black' | | Font color for xtitle. |
xtitleplace | | default: 'c' | | General placement of xtitle: 'c' for center, 'l' for left, 'r' for right. |
| | | | |
xtitlecoord | | default: '' | | Coordinates of title; if empty, guess (you can always |
| | | | adjust final placement with -xtitleshift). |
| | | | |
xtitleshift | | default: [0,0] | | Use this to adjust title place left/right, up/down. |
| | | | |
xtitlerotate | | default: 0 | | How much (in degrees) to rotate the title. |
| | | | |
xtitleanchor | | default: '' | | How to anchor text; empty means best guess. |
| | | | |
xtitlebgcolor | | default: '' | | If not-empty, color behind title. |
ytitle | | default: '' | | Same as with xtitle, but for ytitle. |
ytitlefont | | default: 'default' | | Same as with xtitle, but for ytitle. |
ytitlesize | | default: 10 | | Same as with xtitle, but for ytitle. |
ytitlecolor | | default: 'black' | | Same as with xtitle, but for ytitle. |
ytitleplace | | default: 'c' | | Same as with xtitle, but for ytitle. |
ytitlecoord | | default: '' | | Same as with xtitle, but for ytitle. |
ytitleshift | | default: [0,0] | | Same as with xtitle, but for ytitle. |
ytitlerotate | | default: 90.0 | | Same as with xtitle, but for ytitle (default is different). |
| | | | |
ytitleanchor | | default: '' | | Same as with xtitle, but for ytitle. |
ytitlebgcolor | | default: '' | | Same as with xtitle, but for ytitle. |
title | | default: '' | | Main title of the graph. |
titlefont | | default: 'default' | | Same as with xtitle, but for main title. |
titlesize | | default: 10.0 | | Same as with xtitle, but for main title. |
titlecolor | | default: 'black' | | Same as with xtitle, but for main title. |
titleplace | | default: 'c' | | Same as with xtitle, but for main title. |
titleshift | | default: [0,0] | | Same as with xtitle, but for main title. |
titlerotate | | default: 0 | | Same as with xtitle, but for main title. |
titleanchor | | default: '' | | Same as with xtitle, but for main title. |
titlebgcolor | | default: '' | | Same as with xtitle, but for main title. |
.
Class grid
Just a simple way to draw grids onto graphs. While we generally don't like grids, some people do.
Initialize with following parameters:
drawable | | default: '' | | The relevant drawable upon which to place this grid. |
| | | | |
linecolor | | default: 'black' | | The color of grid lines. |
linewidth | | default: 0.5 | | The width of grid lines. |
linedash | | default: 0 | | Make grid lines dashed as per usual patterns. Examples: |
| | | | 0 for no dashes, [2,2] for length 2 lines with length 2 |
| | | | spaces, etc. |
x | | default: True | | Specify false to turn off grid in x direction |
| | | | (False means no vertical lines). |
y | | default: True | | Specify false to turn off grid in y direction |
| | | | (False means no horizontal lines). |
xrange | | default: '' | | Empty means whole range, otherwise a [y1,y2] as beginning |
| | | | and end of the range to draw vertical lines upon. |
| | | | |
xstep | | default: '' | | How much space to skip between each x. grid line. |
| | | | If log scale, this will be used in a multiplicative manner. |
| | | | |
yrange | | default: '' | | Empty means whole range, otherwise a [x1,x2] as beginning |
| | | | and end of the range to draw horizontal lines upon. |
| | | | |
ystep | | default: '' | | How much space to skip between each y grid line. |
| | | | if log scale, this will be used in a multiplicative manner. |
| | | | |
.
Class legend
Minimal support for legends is provided. Initialize it first (e.g., L = Legend()). Then pass 'L' and other info into plotters. (e.g., legend=L, legendtext='foo'). Finally, call legend.draw() to make the legend on the plot.
Initialize with following parameters:
legend.draw()
Use this to draw a legend given the current entries in the legend.
canvas | | default: '' | | Legend draws directly onto canvas. |
coord | | default: '' | | Where to place the legend (lower left point). |
| | | | Note these are canvas coordinates; if you want to use a |
| | | | drawable's coordinated (e.g., drawable 'd'), call d.map([x,y]) |
| | | | and pass the result into 'coord' here for the desired outcome. |
| | | | |
style | | default: 'right' | | which side to place the text on, right or left? |
| | | | |
width | | default: 10.0 | | width of the picture to be drawn in the legend |
| | | | |
height | | default: 10.0 | | height of the picture to be drawn in the legend |
| | | | |
vskip | | default: 3.0 | | number of points to skip when moving to next legend entry |
| | | | |
hspace | | default: 4.0 | | space between pictures and text |
down | | default: True | | go downward from starting spot when building the legend; |
| | | | false goes upward |
skipnext | | default: '' | | if non-empty, how many rows of legend to print(before) |
| | | | skipping to a new column |
skipspace | | default: 25.0 | | how much to move over if the 'skipnext' option is used to |
| | | | start the next column |
font | | default: 'default' | | which type face to use |
fontsize | | default: 10 | | size of font of legend, and color |
fontcolor | | default: 'black' | | |
order | | default: [] | | can specify a specific legend order ... |