# plot each column separately [duplicate]

I have an 800*161 matrix and I am trying to plot each column with respect to the 1st column.so I tried the following code

ListLinePlot[
{raw[[All, #]] &[{1, 2}],
raw[[All, #]] &[{1, 3}],
raw[[All, #]] &[{1, 4}],
raw[[All, #]] &[{1, 5}]}
]


where 'raw' is my data set, and it shows like this and the which also means I have to repeat 161 times and that's too stupid and nasty code. so I tried the following

ListLinePlot[
Do[{raw[[All, #]] &[{1, i}]}, {i, 2, 161}]
]


but it fails. how can I fix it? Thank you so much!

• Have you seen Table[...]?
– N.B.
Aug 20, 2019 at 15:48
• It appears to be a common misconception about Do (is there a canonical answer?): Do does exactly what its name implies: it Does things. Imagine such a situation: you tell to someone "add 2+2", he replies "ok, done". Then you wait and finally say "you should give me the answer", to which you hear "no, you just wanted me to do the summation, you didn't tell me to return the result or do anything else with it". So, Do does what you tell it to do, but it's not supposed to return anything. Aug 20, 2019 at 20:13

These questions are very similar:

Plot column 1 against list of columns in column 2 (ListPlot)

Plot several columns of table with variable number of columns and display the legend accordingly

Assuming data

data = Table[i j, {i, 9}, {j, 9}];


You can rearrange you data like this

rearrange[dat_] := Array[
dat[[All, {1, #}]] &
, Length[First[dat]] - 1
, 2
]


or

rearrange[dat_] := Function[
mat,
Map[
Transpose[{First[mat], #}] &
, Rest[mat]
]
]@ Transpose[dat]


And plot

ListPlot[
rearrange@data
, PlotTheme -> "Scientific"
, Joined -> True
, PlotStyle -> Array[Hue, Last@Dimensions[data], {0, 0.8}]
]


Something like:

    ListLinePlot[
Table[
RawData[[1;;,{1,col}]],
{col, 2, NumberOfCols}
]
]

ListLinePlot[Table[Transpose[raw[[{1, n}]]], {n, 2, Length[raw]}]]