问题
I have a list that has 5 elements;
{{1, 6, 4.5}, {2, 7, 4.5}, {3, 5, 5}, {4, 8, 5}, {5, 9, 5}, {6, 10, 5}}
I would like to plot this so that the first column is the x-axis, and the other 2 columns would be plotted as lines. Like this:
Line 1 would be have these values 6, 7, 5, 8, 9, 10 and Line 2 would be built in the same manner.
I tired:
ListPlot[data3, Joined -> True, Frame -> True,
FrameLabel -> {"Test Number", "TS Index"}, PlotRange -> All]
The resulting chart was not what I wanted.
How can I plot this as a 2 line plot? Also, what is the technical name for the numbers inside each element?
Thank you in advance.
回答1:
lst = {{1,6,4.5},{2,7,4.5},{3,5,5},{4,8,5},{5,9,5},{6,10,5}}
line1 = lst[[All,{1,2}]]
line2 = lst[[All,{1,3}]]
ListPlot[{line1,line2},Joined->True,Mesh->All,AxesOrigin->{0,0}]

来源:https://stackoverflow.com/questions/12151575/how-to-plot-2-lines-and-spcify-that-the-first-column-in-list-is-the-x-axis