From: Joerg L. <jo...@us...> - 2006-08-29 13:49:34
|
Hello Dani, On 29.08.06, Dani Marti wrote: > Thank you Michael for your answer. I'm glad I was pointing to the good > direction. The concept is now clear to me, but I don't know how to > implement it. From my previous example > > A = generate_graph(0), > > My question is, what precise object should the function "generate_graph" > return? > > Is there anything wrong in > > def generate_graph(parameter): > g = graph.graphxy(width=1, height=1) > g.plot(graph.data.function("y(x)= x**4 - %f * x**2" % parameter, min=-2, max=2)) > return g > > A = generate_graph(1) That's perfect. > > As for the positioning: graph.graphxy() accepts parameters xpos and > > ypos just like the first two parameters of text.text() (or translate > > the graph canvasses). > That's precisely what I prefer not to do: to specify the position at the > very beginning, through the 'graph.graphxy' call inside 'generate_graph'. > This would require to modify the function 'generate_graph' to add a > second argument (the position), which I don't want to do. My idea is to > create the 'floating' figure (using Gimp terminology) and then 'anchor' > it at the position I choose at the end. Is that possible? Just do something like c.insert(A, [trafo.translate(xpos, ypos)]) where c is a canvas and xpos and ypos are the desired positions of the graph. HTH, Jörg |