From: Michael S. <m-s...@us...> - 2004-01-21 18:52:04
|
Hello Sudheer, On 21.01.04, Sudheer Phani wrote: > If I use graph.line() option then all these 5 points are joined with > a line. > > If i were to draw the same graph something like in stem in Matlab... > how would i do it using PYX > > in stem function for each of 5 points to x-axis for e.g from > point(1,4) a line is drawn from (1,4) to (1,0) on x-axis like wise > for the rest of the points I fear that there is no ready-made solution to your problem yet. You can use the following workaround, which is only a small extension to the minimal example: ######## python code ########################### # read x, y values from your datafile d = data.datafile("minimal.dat") # extract the x and y values separately xvals = d.getcolumn(1) yvals = d.getcolumn(2) # plot the top line of your data with a line # (or with symbols, if you like) g = graph(width=8) g.plot(graph.data(d, x=1, y=2), style=graph.line()) # finish the graph so that all axes are fixed g.finish() # now comes the workaround: you can draw lines on the graph-canvas # directly. Use g.pos() for accessing the data-coordinate system: for x,y in zip(xvals,yvals): g.stroke(path.line(g.pos(x,y)[0], g.pos(x,y)[1], g.pos(x,0)[0], g.pos(x,0)[1])) g.writetofile("minimal") ################################################ I hope this answers your question, unfortunately I do not know what the "stem" function in Matlab is ... Best greetings, Michael. -- "A mathematician is a device for turning coffee into theorems" Paul Erdös. |