Reputation: 21
Plot uses columns to plot a square matrix, but I need it by rows.
plot(matrix(1:end,1:end), 1:columns)
works great when matrix is rectangular (plots each line of matrix with a different color), but when matrix is square is plots by column (as the documentation clearly states) I don't want to break the command to a loop because then I will have to specify the color for each line plot.
Is there a way to change the plot defaults to prefer row in square matrices?
Upvotes: 2
Views: 822
Reputation: 5188
You can use a trick and add a line of NaN
at the end of the array:
matrix(end+1,:) = NaN;
And now matrix
is rectangular, but the NaN
won't be displayed during plot.
Best,
Upvotes: 0