How to plot 17 subplots?
29 views (last 30 days)
I am trying to plot a large number of subplots, but want to make sure formartting is such that it takes the most compact form (instead of having 1 row with 17 plots, 2 rows, with 13 and 14 plots, etc). So in this case, I would like 5 rows of plots with 4 plots in each row and 1 in the last row. If 16 plots are selected, then 4 rows with 4 plots, etc.
John BG on 29 Jun 2017
this is John BG ( <mailto:email@example.com firstname.lastname@example.org> )
let be N the amount of images, then the most compact, square-like lay-out is achieved with
plot(..) or stem(..) or any other plot type
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
More Answers (1)
Jan on 30 Jun 2017
Edited: Jan on 30 Jun 2017
This adds a new row only if required:
N = 17;
nS = sqrt(N);
nCol = ceil(nS);
nRow = nCol - (nCol * nCol - N > nCol - 1);
for k = 1:N
subplot(nRow, nCol, k);
plot(1:10, rand(1, 10));
Comparison to the pure square solution: Saving an empty row helps to get the "most compact form", which is not a 5x5 arrangement: