Hi,
On 04.12.06, Riccardo Campana wrote:
> Hello,
> I plotted the points from a data file, e.g.:
> 0.194 0.854
> 0.451 0.907
> 0.660 0.124
> 0.834 0.195
> 0.022 0.911
> 0.055 0.216
> 0.275 0.704
> 0.311 0.554
> 0.641 0.687
> 0.386 0.543
>
> with the standard command
> g = graph.graphxy(width=8,height=8)
> g.plot(graph.data.file("datafile.dat", x=1, y=2), [graph.style.symbol
> (graph.style.symbol.circle, size=0.1, symbolattrs=[deco.filled])])
>
> Now, I want to draw a straight line between some of these points, for
> example from the point (0.194, 0.854) to the point (0.311, 0.554).
>
> How can I do this? With path.line() and stroke() the points are not
> in graph (axis) coordinates...
You're absolutely right. Fortunately we already thought about this and
created some handy conversion methods, which are part of the graph
infrastructure. The only thing you need to understand is that you need
to "finish" the graph (i.e. fix the layout) before you can start using
those conversion methods. Before finishing the graph the axis ranges
are not fixed ...
So all you need to do is to call "g.finish()" after you plot commands.
(Actually a g.dolayout() would already be enough.)
Then you can convert points from axis coordinates to PyX lengths in
the graph "canvas" by g.pos():
x1, y1 = g.pos(0.194, 0.854)
x2, y2 = g.pos(0.311, 0.554)
And than:
g.stroke(path.line(x1, y1, x2, y2))
(I haven't checked the code but it should work along this line.)
HTH,
André
--
by _ _ _ Dr. André Wobst
/ \ \ / ) [EMAIL PROTECTED], http://www.wobsta.de/
/ _ \ \/\/ / PyX - High quality PostScript and PDF figures
(_/ \_)_/\_/ with Python & TeX: visit http://pyx.sourceforge.net/
-------------------------------------------------------------------------
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