arrange_subplots

Automatically computes the #rows and #columns needed to show N subplots.

You are now following this Submission

Automatically computes the #rows and #columns needed to show N subplots. This function takes the size of images into consideration.

Can be used to provide inputs for subplot or subplot_tight

function [nrow, ncol] = arrange_subplots(n,imagesz)

Purpose
Calculate how many rows and columns of sub-plots are needed to
neatly display n subplots. This function considers the size of each subplot.

Inputs
n - the desired number of subplots.
imagesz - [height, width] of each subplot. default([1,1])

Outputs
[nrow, ncol] - defining the number of rows and number of columns required to show n plots.

Example: [nrow, ncol] = arrange_subplots(26, [200,500])
[nrow, ncol] = arrange_subplots(26)

Written by Geng Zhang. (www.bfcat.com). Jan. 2013

Cite As

Geng (2026). arrange_subplots (https://www.mathworks.com/matlabcentral/fileexchange/40024-arrange_subplots), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0