j=0;
ListLinePlot[Table[u[i][j] , {i, 0, Xmax}], PlotRange -> All]
here u is 2 D array and I want to plot all the columns of this 2D matrix in a single graph.
j=0;
ListLinePlot[Table[u[i][j] , {i, 0, Xmax}], PlotRange -> All]
here u is 2 D array and I want to plot all the columns of this 2D matrix in a single graph.
u = Array[# #2 &, {10, 7}];
u // MatrixForm // TeXForm
$\left( \begin{array}{ccccccc} 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 2 & 4 & 6 & 8 & 10 & 12 & 14 \\ 3 & 6 & 9 & 12 & 15 & 18 & 21 \\ 4 & 8 & 12 & 16 & 20 & 24 & 28 \\ 5 & 10 & 15 & 20 & 25 & 30 & 35 \\ 6 & 12 & 18 & 24 & 30 & 36 & 42 \\ 7 & 14 & 21 & 28 & 35 & 42 & 49 \\ 8 & 16 & 24 & 32 & 40 & 48 & 56 \\ 9 & 18 & 27 & 36 & 45 & 54 & 63 \\ 10 & 20 & 30 & 40 & 50 & 60 & 70 \\ \end{array} \right)$
To plot all columns simply Transpose
the matrix u
:
ListLinePlot[Transpose @ u, PlotLegends -> Range[7]]
To plot only a subset of columns, e.g. columns 1, 3, 6, and 7:
ListLinePlot[Transpose[u][[{1, 3, 6, 7}]], PlotLegends -> {1, 3, 6, 7}]