MATLAB: Align subplots non-manually


I have a figure with 5 subplots. Aside from doing it manually, is there are a way to set a 2×3 subplot figure in a way that the first row has 2 subplots and the second row has 3 subplots?
subplot(2,3,1) subplot(2,3,2)
subplot(2,3,3) subplot(2,3,4) subplot(2,3,5)
In way that sub1 and sub2 are centered (so sub1 position should be between sub3 and sub4)

Best Answer

  • Create a 2 row and 6 column grid of locations for subplots. In the first row, each subplot will span 3 of the columns; in the second row, each will span 2. See example "Subplots with Different Sizes" in the documentation for subplot for a simple example of this general technique.