Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Re: [PyX-user] How to plot this function?

 Re: [PyX-user] How to plot this function? From: Andrea Riciputi - 2005-03-22 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*x-b)")) >> g.writeEPSfile("steady") > > Could someone help me out? > > TIA > Martin ```

 [PyX-user] How to plot this function? From: Martin Buchmann - 2005-03-22 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*x-b) 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*x-b)")) I get a lot of error messages: > Traceback (most recent call last): > File "steady-min.py", line 14, in ? > g.writeEPSfile("steady") > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/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/site-packages/pyx/graph/graph.py", line 496, in bbox > self.finish() > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/pyx/graph/graph.py", line 436, in finish > self.domethods[0]() > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/pyx/graph/graph.py", line 328, in dolayout > plotitem.adjustaxes(self, step) > File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/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/site-packages/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/site-packages/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/site-packages/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*x-b)")) > > g.writeEPSfile("steady") Could someone help me out? TIA Martin -- When more and more people are thrown out of work, unemployment results. -- Calvin Coolidge ```
 Re: [PyX-user] How to plot this function? From: Gert Ingold - 2005-03-22 09:20:53 Attachments: Message as HTML ```Hi Martin, > g.plot(graph.data.function("y=3DcNull+dC*exp(-a*x-b)")) try g.plot(graph.data.function("y=3DcNull+dC*exp(-a*x-b)",context=3Dlocals())) instead. This is sort of explained in the example graphs/arrows. Best regards, Gert --=20 Gert-Ludwig Ingold email: Gert.Ingold@... Institut f=FCr Physik Phone: +49-821-598-3234 Universit=E4t Augsburg Fax : +49-821-598-3222 D-86135 Augsburg WWW : http://www.physik.uni-augsburg.de/theo1/ingold Germany PGP : 86FF5A93, key available from homepage ```
 Re: [PyX-user] How to plot this function? From: Martin Buchmann - 2005-03-22 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*x-b)",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? ```
 Re: [PyX-user] How to plot this function? From: Andrea Riciputi - 2005-03-22 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*x-b)")) >> g.writeEPSfile("steady") > > Could someone help me out? > > TIA > Martin ```