JISUBPLOT + NEXTPLOT: enhanced replacement for subplot

버전 1.0.0.0 (270 KB) 작성자: John Iversen
Automatically create complex subplot layouts
다운로드 수: 1.6K
업데이트 날짜: 2006/8/31

라이선스 보기

OVERVIEW: Enhanced replacement for SUBPLOT

Problem:
Multi-axis plotting (using SUBPLOT) is great and essential, but has
shortcomings. The main one is that keeping track of the axis indexes
can be tedious if you want to do anything more elaborate than plotting
in row-order. In addition, the size of all axes are the same, and
spacing is not adjustable.

Solution: JISUBPLOT + NEXTPLOT
What you might really want is to set up a grid of subplots once and
then just tell the figure when you want to move to the next plot,
letting it take care of the details for you.

That's what the pair of functions JISUBPLOT and NEXTPLOT can do.
It decouples the specification of the subplot grid (JISUBPLOT) from the
act of moving around it and creating new axes at various positions
(and sizes) within the grid (NEXTPLOT).

The key that differentiates this solution is NEXTPLOT. Using it,
you can create new axes, automatically move by row, or by column,
or arbitrarily. You can create subplots of mixed sizes. You don' t
need to concern yourself with subplot indexes or coordinates
and can concentrate on how you want the layout to appear.

NEXTPLOT is especially useful in loops where you want create an array of many plots:

jisubplot(2,4,0)
for idx = 1:8,
nextplot('newcol')
plot(something{idx})
nextplot('bycol')
plot(something_related{idx})
end

Finally, wouldn't it be nice if when you changed a figure's orientation (e.g. orient tall), it actually changed shape to reflect that? JISUBPLOT does that.

Examples:

%% the basic idea
figure
jisubplot(4,2,1) % can be used just like SUBPLOT
plot(X)
nextplot % advance to next axis
plot(something_else)
nextplot
plot(some_other_thing)

nextplot('newRow') % start a new row of axes
plot(something_new)
nextplot('byCol') % move down columns
etc...

%% jisubplot / nextplot is especially useful in loops
%% it will extend to new figures automatically
figure
jisubplot(4,4,0) %setup figure, but don't make the first axis
for idx = 1:32,
nextplot('bycol')
title(num2str(idx))
plot(data(idx,:))
end

%% a more complete usage: specify orientation, plot spacing and fontsize
%% figure window is sized appropriately for orientation
figure
jisubplot(5,3,0,'tall',[.3 .3],'fontsize',9)
nextplot
etc...

Run JISUBPLOTDEMO for executable examples of more advanced usage.

Distribution includes:

jisubplot.m -- setup figure for automated multi-pane layout
nextplot.m -- automatically advance to next pane

currentplotis.m -- test location of current axis

jisubplotdemo.m -- demonstration of usage

And the following general utility files (used by nextplot)
These are used for parameter/value argument parsing,
and may be generally of use.

isparam.m -- test for presence of a parameter
getparam.m -- get values following a parameter
strmatch_mixed.m -- strmatch that can be used on cell arrays with non-string elements
useful when parsing parameter/value lists

인용 양식

John Iversen (2024). JISUBPLOT + NEXTPLOT: enhanced replacement for subplot (https://www.mathworks.com/matlabcentral/fileexchange/12103-jisubplot-nextplot-enhanced-replacement-for-subplot), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R14SP1
모든 릴리스와 호환
플랫폼 호환성
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.0.0.0

Improvements to formatting of description.