From: Joerg Lehmann <joergl@us...>  20040830 07:28:02

Hi Andrea, On 30.08.04, Andrea Riciputi wrote: > suppose I want to use functions defined in a python module (namely > Numeric or math) to plot a graph. Defining a function and then using > "context = locals()" doesn't work. Here it is a minimal example: > > import pyx > import math > > def my_f(x): return math.log10(x) > > h = pyx.graph.graphxy(width = 10, height = 10,\ > x = pyx.graph.axis.log(min = .01, max = 100.),\ > y = pyx.graph.axis.log(min = 2, max = +3),\ > key = pyx.graph.key.key(pos = "rb")) > > h.plot(pyx.graph.data.function("y=my_f(x)", context = locals())) > > h.writeEPSfile("minimal.eps") > > In order to get the previous example working I must change "import > math" into "from math import log10" and then change "my_f" definition > accordingly. I'm sure the problem here is my poor understanding of the > "context" parameter, but reading the manual hasn't helped so much. How > can I get the example working as is? If I correct the problem that the minimal axis value for a logarithmic axis must not be negative and set a title for the function (which is necessary because the default title for the key in the present case contains an underscore, this example works for me. math.log10 works fine here. Jörg 