How to plot 2 lines and spcify that the first column in list is the x-axis?

拈花ヽ惹草 提交于 2019-12-12 01:04:51

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!