PDA

View Full Version : Mathematica ListPlot function


brydustin
Mar14-11, 12:22 PM
Suppose that I had a set of Y points Y = {y1,y2,.....yN} and I want to plot them again a set X = {1,2,3,.....,N}

Naturally, I would like to do something like:
YX = { {y1, 1} , {y2,2} , ..... , {yN,N} }
followed by
ListPlot[YX,PlotJoined->True]


My question is: How can I construct YX in a very simple manner?

Bill Simpson
Mar14-11, 03:26 PM
In[1]:= Y={1,5,4}; XY=Transpose[{Y,Range[Length[Y]]}]

Out[2]= {{1,1},{5,2},{4,3}}

brydustin
Mar14-11, 04:59 PM
Thanks........
But what if the set Y was generated in a loop by some arbitrary means, and I wanted to plot Y, and then trash its values, hold the plot, rerun the calculation generating a new Y, and then plot it along with the first Y, keeping the same domain (X).
I know in matlab we would use the HoldOn function, but is there something like this in mathematica?