is it possible to define global title on figures?
152 ビュー (過去 30 日間)
古いコメントを表示
I have subplots with titles, but I want to add a title to the whole figure. Is it possible?
採用された回答
Paul Huxel
2018 年 10 月 9 日
Starting in R2018b, you can use sgtitle to add a title to subplot grids:
0 件のコメント
その他の回答 (3 件)
Brendan Hamm
2015 年 4 月 15 日
Yes this is possible by creating a new axes which takes up much of the figure. Then a title for this axes. Turning the axes Visible property 'off' will make the axes "disappear", but the title will inherit this property and you will need to turn the Visible property for the title back 'on'.
x = 0:0.001:2*pi;
y1 = cos(x);
y2 = sin(x);
f = figure;
subplot(2,1,1)
plot(x,y1)
subplot(2,1,2)
plot(x,y2)
a = axes;
t1 = title('Global Title');
a.Visible = 'off'; % set(a,'Visible','off');
t1.Visible = 'on'; % set(t1,'Visible','on');
Note: In prior versions you may need to use the set command as done in the comments
You may need to tweak the Position property of the axes, a, so the titles do not overlap.
2 件のコメント
K E
2015 年 7 月 16 日
More generally useful; I used it to put a text label on pages containing a variable number of subplots, where I needed the text to appear at the same place on all pages.
Damon Bradley
2022 年 6 月 10 日
The "phantom axes" trick works nicely. This can also be used to add a global colorbar to a tiled layout plot prior to R2020b, where the .Layout property hasn't been defined yet for the colorbar object. Just remember to set the colorbar visibility to 'on', because all of the children of the axes object, once the axes object visibility is set to 'off', by default are also off!
Sean de Wolski
2015 年 7 月 16 日
If you have the Bioinformatics Toolbox you can also use suptitle.
suptitle('I''m a Super Title')
0 件のコメント
Steven Lord
2015 年 7 月 16 日
Do you need a title for printing/exporting purposes or do you need a title in order to distinguish between multiple figures created by the code you're executing? In the latter case another alternative is to set the Name property of the figure.
f = figure;
f.Name = 'First figure';
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!