title below the figure

回答 (2 件)

Jan
Jan 2011 年 4 月 4 日

3 投票

text(0.5, 0.02, 'Title below the axes', ...
'VerticalAlignment', 'bottom', ...
'HorizontalAlignment', 'center');
Another method uses the position of the corresponding AXES:
AxesH = axes;
pos = get(AxesH, 'OuterPosition');
text(pos(1) + pos(3)/2, ...
pos(2) - 0.01, ... % Adjust this to your taste
'Title below the axes', ...
'VerticalAlignment', 'top', ...
'HorizontalAlignment', 'center');
Or you can move the standard title manually:
plot(1:10);
TitleH = title('This is the title');
set(TitleH, 'Position', [0.5, 0.02], ...
'VerticalAlignment', 'bottom', ...
'HorizontalAlignment', 'center')
Or the same using the AXES' OuterPosition again.

1 件のコメント

Isa Duran
Isa Duran 2014 年 5 月 27 日
Hi Jan, I have the same issue. When I use text function on 5 plots, the position of the text isn't the same in them all... What could be the problem? And do you know If its possible to have the title on the left and right side?
Thanks...

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

Robert Cumming
Robert Cumming 2011 年 4 月 4 日

1 投票

when you create the title save its handle i.e.
plot ( x, y );
h = title ( 'my title' );
then insect the h propery position i.e.
pos = get ( h, 'position' )
you can then move your title by:
set ( h, 'position', new_position )
where new_position is the place you want your title to be. It is also worth looking at the Units property to see the different options you have to how to position your title

カテゴリ

ヘルプ センター および File ExchangeLabels and Annotations についてさらに検索

質問済み:

2011 年 4 月 4 日

コメント済み:

2014 年 5 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by