createSquarishSubplotGrid.m 461 B

12345678910111213141516
  1. function hSubplotAxArray = createSquarishSubplotGrid(nSubplots, varargin)
  2. if nargin > 1
  3. spacing = varargin{1};
  4. else
  5. spacing = [0 0];
  6. end
  7. % Closest integer to square root of number of needed subplots.
  8. nRows = ceil(sqrt(nSubplots));
  9. % Now just add the needed colums, here maybe we end up with an extra
  10. % column.
  11. nCols = ceil(nSubplots / nRows);
  12. hSubplotAxArray = arrayfun(@(x) subplot_tight(nRows, nCols, x, spacing), 1: nSubplots);
  13. end