I'm reading the users manual and looking at examples on the web site's
gallery pages (integral seems relevant to me). Attached are two files, one
has the data and testing application code, the other the plotting functions.
Something has been left out. Here's the python traceback:
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 186, in linearDecrCurve
g.plot(x, y)
File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 191, in
plot
plotitems.append(plotitem(self, d, styles))
File "/usr/lib/python2.4/site-packages/pyx/graph/graph.py", line 52, in
__init__
self.title = data.title
AttributeError: 'float' object has no attribute 'title'
What have I done incorrectly, and what's the proper way to assign axes
titles?
Rich
--
Richard B. Shepard, Ph.D. | Integrity Credibility
Applied Ecosystem Services, Inc. | Innovation
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863#!/usr/bin/env python
import os, config, testFunctions
varData =[('Unacceptable','Sustainability','','QualityOfLife','Linear
Decreasing',1,0.0,100.0,0.0,100.0,0.0,100.0,50.0,50.0,100.0,1.0,2),
('Acceptable','Sustainability','','QualityOfLife','Linear
Increasing',2,0.0,100.0,0.0,100.0,0.0,100.0,50.0,50.0,100.0,1.0,2),
('Slow','TimeOfConc','','Hydrology','Decay
S-Curve',1,0.0,50.0,0.0,50.0,0.0,50.0,25.0,25.0,50.0,1.0,3),
('Moderate','TimeOfConc','','Hydrology','Bell
Curve',2,0.0,100.0,0.0,100.0,0.0,100.0,50.0,50.0,50.0,1.0,3),
('Fast','TimeOfConc','','Hydrology','Growth
S-Curve',3,50.0,100.0,50.0,100.0,0.0,100.0,75.0,75.0,50.0,1.0,3),
('Few','Abundance','Fish','Wildlife','Decay
S-Curve',1,0.0,50.0,0.0,50.0,0.0,50.0,25.0,25.0,50.0,1.0,3),
('Moderate','Abundance','Fish','Wildlfie','Bell
Curve',2,0.0,100.0,0.0,100.0,0.0,100.0,50.0,50.0,50.0,1.0,3),
('Many','Abundance','Fish','Wildlife','Growth
S-Curve',3,50.0,100.0,50.0,100.0,50.0,100.0,75.0,75.0,50.0,1.0,3)
]
def testCode():
for row in varData:
curComp = row[3]
curSub = row[2]
curVar = row[1]
plotting = True
if plotting:
if row[4] == 'Decay S-Curve':
testFunctions.zCurve(row[10],row[9])
elif row[4] == 'Bell Curve':
testFunctions.gaussCurve(row[13],row[14])
elif row[4] == 'Growth S-Curve':
testFunctions.sCurve(row[8],row[11])
elif row[4] == 'Beta':
testFunctions.betaCurve(row[13],row[12],row[14])
elif row[4] == 'Data':
continue
elif row[4] == 'Linear Increasing':
testFunctions.linearIncrCurve(row[8],row[11])
elif row[4] == 'Linear Decreasing':
testFunctions.linearDecrCurve(row[10],row[9])
elif row[4] == 'Left Shoulder':
testFunctions.leftShoulderCurve(row[10],row[11],row[9])
elif row[4] == 'Trapezoid':
testFunctions.trapezoidCurve(row[8],row[10],row[11],row[9])
elif row[4] == 'Right Shoulder':
testFunctions.rightShoulderCurve(row[8],row[10],row[11])
elif row[4] == 'Triangle':
testFunctions.triangleCurve(row[8],row[13],row[9])
elif row[4] == 'Singleton':
testFunctions.singletonCurve(row[13],row[14])
elif row[4] == 'Rectangle':
testFunctions.rectangleCurve(row[8],row[10],row[11],row[9])
elif row[4] == 'Outcome':
testFunctions.outcomeCurve()
if row[5] == row[16]:
g.writePDFfile(curVar+'_'+curSub+'_'+curComp+'.pdf')
plotting = False
if __name__ == "__main__":
testCode()
#!/usr/bin/env python
import os, sys, wx, config
import matplotlib
import matplotlib.numerix as nx
from numpy import linalg
from math import *
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
from pyx import *
matplotlib.interactive(False)
def fwhm2k(fwhm): # for matplotlib Gaussian and Singleton curves
"""
Converts fwhm value to k (see above)
"""
return fwhm/(2 * nx.sqrt(nx.log(2)))
def gauss1d(r, fwhm, center):
"""
Returns the 1d gaussian given by fwhm (full-width at half-max),
and c (center) at positions given by r
"""
return nx.exp(-(r-center)**2 / fwhm2k(fwhm)**2)
def boltzman(x, xmid, tau):
"""
Evaluate the boltzman function with midpoint, xmid, and time constant tau
over x
"""
return 1.0 / (1.0 + nx.exp(-(x-xmid)/tau))
# ------------------------------------------------------------------------------
def gaussCurve(midpt, width):
center = midpt
fwhm = width
x = nx.arange(0, 100, 0.1)
G = gauss1d(x, fwhm, center)
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, G)
# ------------------------------------------------------------------------------
def sCurve(left, right):
leftend = left
rightend = right
midpt = ((rightend-leftend)/2.0) + leftend
tau = 5.0
x = nx.arange(leftend, rightend, 0.1)
S = boltzman(x, midpt, tau)
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, S)
# ------------------------------------------------------------------------------
def zCurve(left, right):
leftend = left
rightend = right
midpt = rightend/2.0
tau = 5.0
x = nx.arange(leftend, rightend, 0.1)
Z = 1.0-boltzman(x, midpt, tau)
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, Z)
#------------------------------------------------------------------------------
def trapezoidCurve(ll, hl, hr, lr):
lowLeft = ll
hiLeft = hl
hiRight = hr
lowRight = lr
x, y = zip(*[(lowLeft, 0.0), (hiLeft, 1.0), (hiRight, 1.0), (lowRight, 0.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def leftShoulderCurve(hl, hr, lr):
hiLeft = hl
hiRight = hr
lowRight = lr
x, y = zip(*[(hiLeft, 1.0), (hiRight, 1.0), (lowRight, 0.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def rightShoulderCurve(ll, hl, hr):
lowLeft = ll
hiLeft = hl
hiRight = hr
x, y = zip(*[(lowLeft, 0.0), (hiLeft, 1.0), (hiRight, 1.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def triangleCurve(ll, cen, lr):
lowLeft = ll
center = cen
lowRight = lr
x, y = zip(*[(lowLeft, 0.0), (center, 1.0), (lowRight, 0.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def singletonCurve(cen, width):
center = cen
fwhm = width
x = nx.arange(0, 100, 0.1)
S = gauss1d(x, fwhm, center)
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def betaCurve(cen, inflPt, width):
pass
# ------------------------------------------------------------------------------
def dataCurve(ptList):
pass
# ------------------------------------------------------------------------------
def rectangleCurve(ll, hl, hr, lr):
pass
# ------------------------------------------------------------------------------
def linearIncrCurve(ll, hr):
lowLeft = ll
highRight = hr
x, y = zip(*[(lowLeft, 0.0), (highRight, 1.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def linearDecrCurve(hl, lr):
highLeft = hl
lowRight = lr
x, y = zip(*[(highLeft, 1.0), (lowRight, 0.0)])
p = graph.axis.painter.regular(titlepos=0.3, titledirection=None)
g = graph.graphxy(width=8, x2=None, y2=None,
x=graph.axis.linear(min=0, max=100, title='Universe of
Discourse'),
y=graph.axis.linear(min=0.0, max=1.0, title='Membership
Grade'))
g.plot(x, y)
# ------------------------------------------------------------------------------
def outcomeCurve():
pass
# EOF functions
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user