Hi,

Try taking a look at this minimal example; hopefully it will show you how to do the basic things you need. I'd recommend persevering with PyX. I've found it to be one of the best plotting tools available in terms of producing print-quality figures. (Matplotlib is great for previewing data but I can't stand how you have to jump though hoops to get the figures all the right sizes).

All the best
David

Rich Shepard wrote:
On Tue, 25 Mar 2008, Rich Shepard wrote:

 Something has been left out. Here's the python traceback:

   I modified line 216 in testFunctions.py by appending painter=p to the
graph canvas. That resolved the first error, but replaced it with an axis
data error:

Traceback (most recent call last):
   File "testData.py", line 58, in ?
     testCode()
   File "testData.py", line 37, in testCode
     testFunctions.linearDecrCurve(row[10],row[9])
   File "/data1/eikos/testFunctions.py", line 216, in linearDecrCurve
     painter=p)
   File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 305, in
__init__
     self.axes[axisname] = axis.anchoredaxis(aaxis, self.texrunner, axisname)
   File "/usr/lib/python2.4/site-packages/pyx/graph/axis/axis.py", line 488,
in __init__
     self.data = axis.createdata(errorname)
AttributeError: regular instance has no attribute 'createdata'

   What is now missing?

Rich


--
===========================================
David Barton
Email:  [EMAIL PROTECTED]
Web:    www.cityinthesky.co.uk
===========================================
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')
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to