1
$\begingroup$

I have seen many examples that show how to plot several functions on the same graph using ListLinePlot is this manner:

e.g. ListLinePlot[{data1, data2}].

In my case, I have an $M \times N$ matrix, for example $8192 \times 12$, stored in a single variable called myMatrix. Is there a simple way to pass myMatrix to ListLinePlot so that each $8192 \times 1$ "column vector" is plotted as a distinct line on the same plot?

$\endgroup$
2
$\begingroup$

Reference: Part

ListLinePlot[{myMatrix[[All,1]],myMatrix[[All,2]], ...}]

data = {{1, 5, 10}, {1, 5, 10}, {1, 5, 10}, {1, 5, 10}, {1, 5, 10}};
ListLinePlot[{data[[All, 1]], data[[All, 2]], data[[All, 3]]}]]

enter image description here

Or for a compact, universal solution (Courtesy of J.M.)

ListLinePlot[Transpose[myMatrix]]
$\endgroup$
2
  • 2
    $\begingroup$ ListLinePlot[Transpose[data]] is more compact. $\endgroup$
    – J. M.'s torpor
    Jul 17 '16 at 0:59
  • $\begingroup$ @J.M. Thank you $\endgroup$
    – Young
    Jul 17 '16 at 1:04

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.