From: Sudheer Phani <bpsu@it...>  20040122 12:58:08

Hi Michael I some how could nt the graph i wanted to. Well abt the stem function in the matlab. eg y = x*x for x in the range (0,5) we have y = [0,1,4,9,16] when i stem(y) in matlab ... we get a graph some thing like this !!! ^ Y     a    x    i     s           > 0 1 2 3 4 Xaxis > where the height of each line corresponds to the value of y i.e. (0,1,4,9,16) for x = [0,1,2,3,4] regds Sudheer > 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 xaxis for e.g from > > point(1,4) a line is drawn from (1,4) to (1,0) on xaxis like wise > > for the rest of the points > > I fear that there is no readymade 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 graphcanvas > # directly. Use g.pos() for accessing the datacoordinate 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. > > 