Simple Tutorial

A Graphite user plots data by creating a Graph object, and attaching data sources and formats. A typical usage is shown below.

Typical Usage

Given a file with x and y values we want to graph a line.


simplexy.dat
1	4
2	9
3	7
4	10
5	8

These python commands create a new graph object, and sets its data from a text file using the utility function loadTable. This data is then used to create a Dataset which is appended to the graphs list of datasets.
	from graphite import *
	graph = Graph()
	file = open('simplexy.dat')
	data = loadTable('simplexy.dat','\t')
	graph.datasets.append(Dataset(data))
Next, we create a PointPlot format with a red line with width 2 for the line style. The second command appends this format to the list of plot formats which the graph mantains.
	lineplot = PointPlot( lineStyle = LineStyle(color=red, width=2) )
	graph.formats.append( lineplot ) 
Finally we output the graph to a PDF file using the utitlity function genOutput.
	genOutput(graph,'PDF',size=(400,250))


http://Graphite.sourceforge.net/simpletutorial.html
Last Updated: 1/12/00. . . . . .mstrout@cs.ucsd.edu