Hi folks,
I want to upgrade from 0.8.1 to 0.9. However, I have code that refuses
to work with the new version. Could any of you please have a look at
it and tell me what I should change? Thanks a lot in advance!
Sorry for the Dutch by the way, but the code is part of a Dutch
financial calculation package.
"Jaartal" means "year"
"Aanwezig inkomen" means "Available income"
"Gewenst inkomen" means "Wanted income"
"Tekort" means "Short"
The code:
def plotbars(filename, *args):
'''Plots een bargraph.
De grafiek wordt opgeslagen als EPS in de file genaamd 'filename'.
De argumenten moeten tuples zijn van vier waarden:
- Jaartal
- Aanwezig inkomen
- Gewenst inkomen
- Tekort
'''
log.debug('Plotting graph in "%s"' % filename)
# Create the graph, with the proper colours and key.
palette = UPNPalette()
mynestedbaraxis = pyx.graph.axis.bar(
defaultsubaxis=pyx.graph.axis.bar(
dist=0.2,
painter=None
)
)
key = pyx.graph.key.key(hinside=0)
texter = pyx.graph.axis.texter.decimal()
g = pyx.graph.graphxy(
width=8,
x=mynestedbaraxis,
y=pyx.graph.axis.linear(texter=texter),
key=key
)
aanwezig_data = [(a[0], a[1]) for a in args]
gewenst_data = [(a[0], a[2]) for a in args]
tekort_data = [(a[0], a[3]) for a in args]
# Build a list data lists
gewenst = pyx.graph.data.list(gewenst_data, xname=1, y=2, title='Gewenst')
aanwezig = pyx.graph.data.list(aanwezig_data,xname=1, y=2, title='Aanwezig')
tekort = pyx.graph.data.list(tekort_data, xname=1, y=2, title='Tekort')
# Draw the graph
g.plot([gewenst, aanwezig, tekort],
[
pyx.graph.style.barpos(fromvalue=0),
pyx.graph.style.bar([palette])
])
# Write the EPS
g.writeEPSfile(filename)
def main():
plot = plotbars('plot1',
(2030, 12410, 93021, -3020),
(2031, 12410, 93021, -3020),
(2036, 12410, 93021, -3020)
)
The error message:
File "/home/sybren/live-20060616-1017/upn/plotter/__init__.py", line 87, in
plotbars
g.writeEPSfile(filename)
File "/home/sybren/packages/PyX-0.9/pyx/canvas.py", line 329, in
wrappedindocument
return method(d, file)
File "/home/sybren/packages/PyX-0.9/pyx/document.py", line 155, in
writeEPSfile
pswriter.epswriter(self, file, *args, **kwargs)
File "/home/sybren/packages/PyX-0.9/pyx/pswriter.py", line 278, in __init__
page.processPS(pagefile, self, acontext, registry, pagebbox)
File "/home/sybren/packages/PyX-0.9/pyx/document.py", line 138, in processPS
self._process("processPS", *args)
File "/home/sybren/packages/PyX-0.9/pyx/document.py", line 81, in _process
getattr(self.canvas, processMethod)(canvasfile, writer, context, registry,
bbox)
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 157, in
processPS
self.finish()
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 250, in finish
self.doaxes()
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 472, in doaxes
self.dolayout()
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 456, in dolayout
self.doaxiscreate(axisname)
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 449, in
doaxiscreate
self.doaxispositioner(axisname)
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 411, in
doaxispositioner
self.doranges()
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 200, in doranges
plotitem.adjustaxesstatic(self)
File "/home/sybren/packages/PyX-0.9/pyx/graph/graph.py", line 79, in
adjustaxesstatic
style.adjustaxis(privatedata, self.sharedata, graph, columnname, data)
File "/home/sybren/packages/PyX-0.9/pyx/graph/style.py", line 1249, in
adjustaxis
graph.axes[sharedata.barposcolumnnames[i][:-4]].adjustaxis([self.addsubvalue(x,
0) for x in data])
File "/home/sybren/packages/PyX-0.9/pyx/graph/axis/axis.py", line 512, in
adjustaxis
self.axis.adjustaxis(self.data, columndata, self.graphtexrunner,
self.errorname)
File "/home/sybren/packages/PyX-0.9/pyx/graph/axis/axis.py", line 364, in
adjustaxis
"%s, subaxis %s" % (errorname, name))
File "/home/sybren/packages/PyX-0.9/pyx/graph/axis/axis.py", line 341, in
adjustaxis
raise ValueError("tuple expected by bar axis '%s'" % errorname)
ValueError: tuple expected by bar axis 'x, subaxis 2018'
Again, thanks to anyone willing to help.
--
Sybren Stüvel, B.Sc.
Stüvel IT
http://www.stuvel.eu/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user