Set same axis limits to all currently open plots.

버전 1.2.0.0 (3.6 KB) 작성자: Johannes Keyser
SAMEAXES unifies/synchronizes axis limits on different axes and subplots.
다운로드 수: 644
업데이트 날짜: 2014/5/21

라이선스 보기

SAMEAXES unifies/synchronizes axis limits on different axes and subplots.
Calling sameaxes() sets identical limits [the pooled min() and max()] to
each axis respectively - which is very handy to compare different plots!
It is possible to restrict the effect to a specific figure and/or axis:
Use XYZC to select which axis to unify (e.g. only the y- or color-axis),
and HNDS to restrict the operations to e.g. only the current figure.
Note that it doesn't link any axes as done by linkaxes().
You may exclude a figure or axis by setting 'HandleVisibility' to 'off'.
Many examples below.
INPUT
XYZC - which axis to sync (cell or char array) [default 'xyzc' ==> all]
HNDS - figure handle(s) to search for children [default 0 ==> all axes]

OUTPUT
none; re-sets the [xyzc]lim-properties of HNDS objects' children axes

EXAMPLES
sameaxes() without arguments unifies ALL existing axes (x, y, z, color)
sameaxes('y') applies to the ylim of ALL existing axes (across figures)
sameaxes('xc', gcf()) unifies only the x-axis- and color-limits of all
subplots that are children of the current figure
sameaxes([], [fg1,fg2]) separately unifies children of figures fg1, fg2

In case you want to exclude certain figures or axes from being
affected, you can set their handles' visibilities to 'off' beforehand.
Here an example with 5 figures, excluding the first and the fifth:
for ii = 1:5
figure(), plot(ii*rand(10)), title(sprintf('plot %d', ii))
end
figures = flipud(findobj('Type','figure')); % get figure handles
exclude = figures([1 5]); % select 1,5 for exclusion
set(exclude, 'HandleVisibility', 'off') % set handles "invisible"
sameaxes() % sync all visible handles
set(exclude, 'HandleVisibility', 'on') % restore to default

See also PBASPECT, DASPECT, LINKAXES, XLIM, YLIM, ZLIM.

인용 양식

Johannes Keyser (2024). Set same axis limits to all currently open plots. (https://www.mathworks.com/matlabcentral/fileexchange/45219-set-same-axis-limits-to-all-currently-open-plots), MATLAB Central File Exchange. 검색됨 .

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

Community Treasure Hunt

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

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

1) Fixed assertion-check for valid input handles.

2) Added an example to exclude figure or axis handles from being affected by setting their 'Handlevisibility' to 'off'.

1.1.0.0

Added another example and clarified some sentences in the description.