from pyx import *
from numpy import *
# A list of x,y pairs
data = random.random((30,2))
data[:,0] *= 100
# Turn this into data for PyX - if you are using PyX v0.10 then this should use graph.data.point(s?) instead
data2plot = graph.data.list(data,
x = 1,
y = 2) # the x =, y = tells PyX which columns of the data to use
# column zero is the index (i.e., 0 to len(data[:,0]))
# Painter for the axes
p = graph.axis.painter.regular(titlepos = 1, titledist = 0.1, labeldist = 0.1)
# First minimal example - note how painter applied to one axis only
g = graph.graphxy(width = 8,
x = graph.axis.linear(min = 0, max = 100, title = 'Axis one', painter = p),
y = graph.axis.linear(min = 0, max = 1, title = 'Axis two'),
x2 = None,
y2 = None)
# Plot the data
g.plot(data2plot)
# Save the plot
g.writePDFfile('example1')
# A second plot
g2 = graph.graphxy(width = 8,
x = graph.axis.linear(min = 0, max = 100, title = 'Axis one', painter = p),
y = graph.axis.linear(min = 0, max = 1, title = 'Axis two'),
x2 = None,
y2 = None)
# Plot the data
g2.plot(data2plot,[graph.style.line()])
# Write out the plot
g2.writePDFfile('example2')
# A third plot
g3 = graph.graphxy(width = 8,
x = graph.axis.linear(min = 0, max = 100, title = 'Axis one', painter = p),
y = graph.axis.linear(min = 0, max = 1, title = 'Axis two'),
x2 = None,
y2 = None)
# Plot the data connected by lines with filled circles at the data points
g3.plot(data2plot,[graph.style.line([style.linestyle.dashed,
color.rgb.green]),
graph.style.symbol(symbol = graph.style.symbol.circle,
size = 0.1,
symbolattrs = [deco.filled([color.rgb.blue]),
deco.stroked([color.rgb.red])])])
# Write out the plot
g3.writePDFfile('example3')