0
$\begingroup$

This question already has an answer here:

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 enter image description here 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!

$\endgroup$

marked as duplicate by rhermans, C. E., corey979, eyorble, m_goldberg plotting Aug 20 at 23:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Have you seen Table[...]? $\endgroup$ – Q.P. Aug 20 at 15:48
  • 1
    $\begingroup$ 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. $\endgroup$ – corey979 Aug 20 at 20:13
1
$\begingroup$

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}]
 ]

enter image description here

$\endgroup$
0
$\begingroup$

Something like:

    ListLinePlot[
                   Table[
                           RawData[[1;;,{1,col}]],
                           {col, 2, NumberOfCols}
                        ]
                ]
$\endgroup$
0
$\begingroup$
ListLinePlot[Table[Transpose[raw[[{1, n}]]], {n, 2, Length[raw]}]]
$\endgroup$

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