How to make subplot go down the column and not across the row in the first instance?
135 views (last 30 days)
I have a question that I can't seem to figure out. So, I am using subplots to combine two matrices I wish to combine in one diagram. Each matrix has 5 variables that will be plotted. Specifically, I am trying to combine them such that they appear in a 5 rows by 2 columns diagram. I am able to do that. But, when using subplot to combine these 10 figures into the same diagram, Matlab goes across the columns before heading down to the second row when plotting these figures. Is there anyway to make Matlab fill up the first column first before going onto the second column, without specifying the 10 subplots individually (as they are all in 2 matrices)?
Matt J on 22 Jun 2013
Why not just change the order of the images instead of trying to change the order of the figure plotting. For example, suppose your images exist in a 5x2 cell array. Then just transpose the array,
Romain on 11 Oct 2016
Edited: Romain on 11 Oct 2016
Since I faced the same issue today here an easy solution. I tweaked the subplot script so that it fills the columns first and it works quite well. Go to lines 291-292 and change them as
%row = (nRows - 1) - fix((plotId - 1) / nCols);
%col = rem(plotId - 1, nCols);
% lines to change:
col = (nCols - 1) - ((nCols - 1) - fix((plotId - 1) / nRows));
row = (nRows - 1) - (rem(plotId - 1, nRows));