Plotting multiple figures using subplot

3 views (last 30 days)
sam
sam on 22 Dec 2022
Answered: VBBV on 26 Feb 2024
How I can plot like this?
Fig1 Fig2
Fig3 Fig4
Fig5 Fig6

Answers (2)

John D'Errico
John D'Errico on 22 Dec 2022
help subplot
SUBPLOT Create axes in tiled positions SUBPLOT(m,n,p) divides the current figure into an m-by-n grid and creates an axes in the position specified by p. MATLAB® numbers subplot positions by row. The first subplot is the first column of the first row, the second subplot is the second column of the first row, and so on. If an axes exist in the specified position, then this command makes the axes the current axes. SUBPLOT(m,n,p,'replace') deletes the existing axes in position p and creates a new axes. SUBPLOT(m,n,p,'align') creates a new axes so that the plot boxes are aligned. This option is the default behavior. SUBPLOT(m,n,p,ax) converts the existing axes, ax, into a subplot in the same figure. SUBPLOT('Position',pos) creates an axes in the custom position specified by pos. Use this option to position a subplot that does not align with grid positions. Specify pos as a four-element vector of the form [left bottom width height]. If the new axes overlaps existing axes, then the new axes replaces the existing axes. SUBPLOT(___,Name,Value) modifies axes properties using one or more name-value arguments. Set axes properties after all other input arguments. ax = SUBPLOT(___) creates an Axes object, PolarAxes object, or GeographicAxes object. Use ax to make future modifications to the axes. SUBPLOT(ax) makes the axes specified by ax the current axes for the parent figure. This option does not make the parent figure the current figure if it is not already the current figure. Example: subplot(2,1,1); x = linspace(0,10); y1 = sin(x); plot(x,y1) subplot(2,1,2); y2 = sin(5*x); plot(x,y2) See also TILEDLAYOUT, NEXTTILE, SGTITLE, AXES, GCA Documentation for subplot doc subplot
  1 Comment
sam
sam on 22 Dec 2022
Could you please show it with an example to get the following plot?
Fig1 Fig2
Fig3 Fig4
Fig5 Fig6

Sign in to comment.


VBBV
VBBV on 26 Feb 2024
subplot(3,2,1)
plot(rand(2),rand(2)); title('figure 1')
subplot(3,2,2)
plot(rand(2),rand(2));title('figure 2')
subplot(3,2,3)
plot(rand(2),rand(2));title('figure 3')
subplot(3,2,4)
plot(rand(2),rand(2));title('figure 4')

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!