subplot position

버전 1.1.0.0 (8.02 KB) 작성자: Yuheng
Calculate the position of subplots when you want to plot similar figures togather.
다운로드 수: 100
업데이트 날짜: 2016/10/24

라이선스 보기

subplot_position Calculate position of subplot axis
[P_SUBPLOT,P_FIG] = subplot_position(X_WIDE,Y_WIDE,X_NUM,Y_NUM,FLAG_COLORBAR)
x_wide, y_wide are width of x and y direction, in pixels
x_num, y_num are number of figs in one row and column
flag_colorbar(optional): 0 without colorbar, 1 with X-direction
colorbar, 2 with Y-direction colorbar, 3 with X-dir bar separated,
4 with Y-dir bar separated.
P_subplot is a cell array of the sub figure positions, used in
subplot('position',P_subplot{II}), II is

--------------------------
| 1 | 2 | 3 |
--------------------------
| 4 | 5 | 6 |
--------------------------

P_fig is the total width of big figure in pixels
figure('Position',P_fig)
[...,P_COLORBAR] = subplot_position(...)
P_colorbar is colorbar position
colorbar('Position',P_colorbar)
if flag_colorbar = 0, these will be 0 too
[...,imode_axis] = subplot_position(...)
imode_axis is a vector of struct saves the mode of x/y labels
imode_axis.x = 1 means x label on
= 0 means x label off
imode_axis.y = 1 means y label on
= 0 means y label off
[...] = subplot_position(...,X_GAP,Y_GAP,C_GAP,C_WIDE)
x_gap, y_gap are gaps between figs, default is 50
c_gap is gap between colorbar and fig, default also 50
c_wide is width of colorbar, default is 30
[...] = subplot_position(...,X_GAP,Y_GAP,C_GAP,C_WIDE,X_BORDER,Y_BORDER)
x_border,y_border are additional gaps at borders, default is 0

Notice:
If you want to make no gap between 2 subplots, make sure the ratio
of X_WIDE/Y_WIDE equal to the DataAspectRatio between X and
Y-direction of the certain axis.

Example 1:
[P_subplot,P_fig,P_colorbar] = subplot_position(300,300,2,2,0,5,5,30,30,50,50);
figure('Position',P_fig)
subplot('position',P_subplot{1})
ezplot(@sin,[0,2*pi,-2,2])
set(gca,'XTickLabel',[])
subplot('position',P_subplot{2})
ezplot(@cos,[0,2*pi,-2,2])
set(gca,'XTickLabel',[])
set(gca,'YTickLabel',[])
subplot('position',P_subplot{3})
ezplot(@tan,[0,2*pi,-2,2])
subplot('position',P_subplot{4})
ezplot(@cot,[0,2*pi,-2,2])
set(gca,'YTickLabel',[])

Example 2:
[P_subplot,P_fig,P_colorbar,imode_axis] = subplot_position(300,300,3,2,1);
figure('Position',P_fig)
for ii = 1:6
subplot('position',P_subplot{ii})
if ~imode_axis(ii).x
set(gca,'XTickLabel',[])
end
if ~imode_axis(ii).y
set(gca,'YTickLabel',[])
end
end
colorbar('SouthOutside','Position',P_colorbar)

인용 양식

Yuheng (2025). subplot position (https://kr.mathworks.com/matlabcentral/fileexchange/56261-subplot-position), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2015a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Subplots에 대해 자세히 알아보기
태그 태그 추가

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

+Add an output imode_axis, see example 2 for detail.

1.0.0.0