labelEdgeSubPlots

버전 1.6.0.0 (2.35 KB) 작성자: Rob Campbell
Automatically apply x and y labels to subplots only along the edges.
다운로드 수: 1.6K
업데이트 날짜: 2012/7/11

라이선스 보기

편집자 메모: This file was selected as MATLAB Central Pick of the Week

function H=labelEdgeSubPlots(xl,yl,onlyBottom)

Purpose
If all subplots have the same quantities on the x and y axes then
there's no point labeling all of them. Often it looks neater to
simply have y labels only on the plots along the left hand
edge and x labels only on the plots along the bottom. This
function does this automatically for the current figure.

Inputs
xl - a string specifying what to label the x axes.
yl - a string specifying what to label the y axes.
onlyBottom - by default this is zero and the function adds an
x-axis to appropriate plots from the penultimate row
if the bottom row of plots is incomplete. set
onlyBottom to 1 to suppress this behaviour.
* in addition: onlyBottom can be a vector of axis handles to
be processsed.
Outputs
H - a structure containing handles to the x and y axis labels

Example
clf
for i=1:5
subplot(2,3,i)
x=[0:10]; y=1+0.01*x.^3+randn(size(x))*0.2;
plot(x,y,'ok'), xlabel('will be removed')
end

H=labelEdgeSubPlots('beer [pints]','faux pas');
%or:
H=labelEdgeSubPlots('beer [pints]','faux pas',1);
%One can also do:
set(H.xlabels,'color','red','fontweight','bold')

%proccess only some subplots
ax=[];
for i=1:25
subplot(5,5,i), box on
if mod(i,5)==1, ax=[gca,ax]; end
end
labelEdgeSubPlots('X','Y',ax);

Rob Campbell - January 2009

인용 양식

Rob Campbell (2024). labelEdgeSubPlots (https://www.mathworks.com/matlabcentral/fileexchange/26332-labeledgesubplots), MATLAB Central File Exchange. 검색됨 .

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

And another correction to the help...

1.5.0.0

Fixed error in one of the exampled.

1.3.0.0

Add H1 line

1.2.0.0

Returns label handles.
3rd input can now also be a vector of axis handles to be labeled.

1.1.0.0

Now skips axes which are Matlab-generated legends or colorbars. Please let me know if it gets confused by other figure child elements.

1.0.0.0