Plotting multiple figures using subplot

3 次查看(过去 30 天)
sam
sam 2022-12-22
回答: VBBV 2024-2-26
How I can plot like this?
Fig1 Fig2
Fig3 Fig4
Fig5 Fig6

回答(2 个)

John D'Errico
John D'Errico 2022-12-22
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 个评论
sam
sam 2022-12-22
Could you please show it with an example to get the following plot?
Fig1 Fig2
Fig3 Fig4
Fig5 Fig6

请先登录,再进行评论。


VBBV
VBBV 2024-2-26
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!

Translated by