2

Suppose that I have a following data:

tab = {{1,2,-3,5}, {5,-2,3,1}, {2,0,4,5}};

I want to make a ListPlot based on tab as follows:

  1. Focusing on the first and the second column, plot (1,2), (5,-2), (2,0).
  2. Focusing on the first and the third column, plot (1,-3), (5,3), (2,4).
  3. Focusing on the first and the last column, plot (1,5), (5,1), (2,5).

I want to make the colors in three groups 1., 2., and 3. different. How can I achieve this? (Of course, this is a simple example and my real data has a large number of points, but the number of column can be handled by hand.)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Laplacian
  • 1,053
  • 3
  • 8

1 Answers1

3

Let's say your data looks like this

data = Transpose@Join[{0.1*Range[10]},Sort/@RandomReal[1,{10,10}]];
TableForm@data

enter image description here

You can ListPlot all columns except the first against the first column, without specifying the number of columns, like this

With[
    {n=Length[First@data]},
    ListLinePlot[
        Table[
            data[[All,{1,j}]]
            ,{j,2,n}
        ]
        , PlotStyle  -> Array[Hue,n,{0,0.8}]
        , PlotLegends-> Table[StringTemplate["`` vs ``"][j,1],{j,2,n}]
    ]
]

enter image description here

rhermans
  • 36,518
  • 4
  • 57
  • 149