how to give labels and title to all subplot one time

12 ビュー (過去 30 日間)
moonman
moonman 2011 年 12 月 6 日
コメント済み: Anvya 2015 年 10 月 19 日
I am having 12 subplots in my figure All are required to have same labels How can i give them label by mentioning only one time?

採用された回答

Abhishek Gupta
Abhishek Gupta 2011 年 12 月 6 日
One may use FINDOBJ to locate all subplots/axes on a figure and then use a FOR loop to label/title all the subplots. For example:
f=figure;
subplot(2,2,1:2)
text(.5,.5,'subplot(2,2,1:2)',...
'FontSize',14,'HorizontalAlignment','center')
subplot(2,2,3)
text(.5,.5,'subplot(2,2,3)',...
'FontSize',14,'HorizontalAlignment','center')
subplot(2,2,4)
text(.5,.5,'subplot(2,2,4)',...
'FontSize',14,'HorizontalAlignment','center')
ax = findobj(f,'Type','Axes');
for i=1:length(ax)
ylabel(ax(i),{'Nice'})
title(ax(i),{'Very Nice'})
end
Hope this helps.
Abhi...
  2 件のコメント
Naz
Naz 2011 年 12 月 6 日
Since all of your subplots have the same labels, I would label only the left subplots for y-axes and bottom subplots for x-axes. This way your plots look a little bigger because your labels don't take extra space.
Anvya
Anvya 2015 年 10 月 19 日
Thank you!
I may use anywhere between 2-4 subplots and I wanted the title only once. I used
demo1=figure(1);
plot(x,y)
ax = findobj(demo1,'Type','Axes')
title(ax(length(ax)),'my Title')
Note the index of 'ax'. I have used the last one because it gets the axes in the reverse order. If you use ax(1), the title will be on the last subplot.

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2011 年 12 月 6 日
FigH = figure;
subplot(1,2,1); subplot(1,2,2);
AxesH = findobj(FigH, 'Type', 'Axes');
YLabelHC = get(AxesH, 'YLabel');
YLabelH = [YLabelHC{:}];
set(YLabelH, 'String', 'Y-label')
TitleHC = get(AxesH, 'Title');
TitleH = [TitleHC{:}];
set(TitleH, 'String', 'The title');
  1 件のコメント
lhwang
lhwang 2015 年 8 月 20 日
Very helpful, thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by