I have a CSV file with $9$ columns. I want to plot them in the following way. Column $1$ will be along the $X$-axis. Any point $(x_i, y_i)$ of $i$-th curve in the plot will have the $x$ value from the corresponding row of column $1$ and the $y$ value from the $x$-th row of the $(i-1)$-th column. So, there will be $8$ curves in the plot. The file could be downloaded from this link. The code is:

data = Import["iso-pair-data.csv", "CSV"]; ListPlot[{data[[All, 2]],
data[[All, 3]], data[[All, 4]]}, Joined -> True, PlotMarkers -> Automatic]

I am not getting the plot as expected. Any help?

  • 1
    $\begingroup$ I think this is what you're trying to do: ListPlot[Rest@Transpose@data, Joined -> True, PlotRange -> Full] $\endgroup$ – C. E. Jul 16 '14 at 20:40
  • 1
    $\begingroup$ I do not get it. Lets say i=2, ok? So the first column is the x-values, fine. Now the y-values you are saying come from the rows of the (i-1) column? but this is 1 in this case? But that is supposed to be the x-values for all the other columns. Are you simply trying to plot columns 2-9 against the first column? $\endgroup$ – Nasser Jul 16 '14 at 20:40
  • 1
    $\begingroup$ @Nasser It should be i+1... if you use all the information in the question I don't think there can be any doubt. $\endgroup$ – C. E. Jul 16 '14 at 20:43

Does this work for you?

vals = Table[Transpose[{data[[All, 1]], data[[All, i]]}], {i, 2, 
ListLinePlot[vals, Joined -> True, 
 PlotRange -> {Automatic, {0, Max[data[[All, 2 ;;]]]}}, 
 ImageSize -> Large]

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.