From: Martin Buchmann <Martin.B<uchmann@un...>  20050322 09:09:03

Hi all, i'm pretty new to PyX and to Python in general but i find it very usefull closing some gaps i'm facing between gnuplot and Metapost. At the moment i try to plot the function y(x) = c0 + DC*exp(a*xb) where c0, DC, a and b are just constant values i want to set before plotting and maybe change until the plot looks the way i want to have it. If i just try it the way gnuplot would use, i.e. setting the constants and then do something like this: g.plot(graph.data.function("y=cNull+dC*exp(a*xb)")) I get a lot of error messages: > Traceback (most recent call last): > File "steadymin.py", line 14, in ? > g.writeEPSfile("steady") > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/canvas.py", line 424, in writeEPSfile > abbox = bbox is not None and bbox or self.bbox() > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/graph/graph.py", line 496, in bbox > self.finish() > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/graph/graph.py", line 436, in finish > self.domethods[0]() > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/graph/graph.py", line 328, in dolayout > plotitem.adjustaxes(self, step) > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/graph/graph.py", line 186, in adjustaxes > self.data.adjustaxes(self, graph, step) > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/graph/data.py", line 647, in adjustaxes > y = self.mathtree.Calc(**self.context) > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/mathtree.py", line 582, in Calc > return HIDDEN_self.Args[0].Calc(**args) + HIDDEN_self.Args[1].Calc(**args) > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/sitepackages/pyx/mathtree.py", line 154, in Calc > return MathConst[HIDDEN_self.Args[0]] > KeyError: 'cNull' So, i guess this try was just too naive. But as i don't know Python right now i wasn't able to find out how to specify the function. > from pyx import * > > cNull = 3.0 > dC = 4.5 > a = 1 > b = 0.5 > > g = graph.graphxy(width=8, > x=graph.axis.linear(min=0, max=1, title="$x$"), > y=graph.axis.linear(title="$c$")) > > g.plot(graph.data.function("y=cNull+dC*exp(a*xb)")) > > g.writeEPSfile("steady") Could someone help me out? TIA Martin  When more and more people are thrown out of work, unemployment results.  Calvin Coolidge 
From: Gert Ingold <Gert.Ingold@Physik.UniAugsburg.DE>  20050322 09:20:53
Attachments:
Message as HTML

Hi Martin, > g.plot(graph.data.function("y=3DcNull+dC*exp(a*xb)")) try g.plot(graph.data.function("y=3DcNull+dC*exp(a*xb)",context=3Dlocals())) instead. This is sort of explained in the example graphs/arrows. Best regards, Gert =20 GertLudwig Ingold email: Gert.Ingold@... Institut f=FCr Physik Phone: +498215983234 Universit=E4t Augsburg Fax : +498215983222 D86135 Augsburg WWW : http://www.physik.uniaugsburg.de/theo1/ingold Germany PGP : 86FF5A93, key available from homepage 
From: Martin Buchmann <Martin.B<uchmann@un...>  20050322 09:29:52

Gert, Gert Ingold said the following on 22.03.2005 10:20 Uhr: > try > g.plot(graph.data.function("y=cNull+dC*exp(a*xb)",context=locals())) > instead. This is sort of explained in the example graphs/arrows. Thanks :) That works for me. Best regards Martin  What good is a ticket to the good life, if you can't find the entrance? 
From: Andrea Riciputi <ariciputi@pi...>  20050322 09:23:24

Try to declare your function as a Python function: from pyx import * def myfunc(x, cNull, dC, a, b): return cNull + dC * exp(a*x  b) cNull = 3.0 dC = 4.5 a = 1 b = 0.5 g = graph.graphxy(...) g.plot(graph.data.function("y = myfunc(x)", context = {"myfunc":myfunc})) g.writeEPS(...) HTH, Andrea. On 22 Mar 2005, at 10:08, Martin Buchmann wrote: > So, i guess this try was just too naive. But as i don't know Python > right now i wasn't able to find out how to specify the function. > >> from pyx import * >> cNull = 3.0 >> dC = 4.5 >> a = 1 >> b = 0.5 >> g = graph.graphxy(width=8, >> x=graph.axis.linear(min=0, max=1, title="$x$"), >> y=graph.axis.linear(title="$c$")) >> g.plot(graph.data.function("y=cNull+dC*exp(a*xb)")) >> g.writeEPSfile("steady") > > Could someone help me out? > > TIA > Martin 