Plot title disappears if ymax < 1

My plot titles are disappearing if ymax is less than 1, presumably because the " X 10^-2" bit ends up in the area where the title goes. It is not affected by the length (number of characters) of the plot title. I have only noticed this since I started shrinking my plots vertically from the default size so that three of them will fit on one page in a word document file.
The code for shrinking vertically:
currentSize = get(gcf, 'Position');
set(gcf, 'Position', [currentSize(1) currentSize(2) currentSize(3) 280])
My current workaround is to increase the plot window size, add the title, then reduce the plot size back:
figurePosition = get (gcf, 'Position');
set (gcf, 'Units', 'normalized', 'Position', [0,0,1,1]);
% add plot titles etc here
set (gcf, 'Units', 'pixels', 'Position', figurePosition);
This works for long plot titles, even if the text overlaps the " X 10^-2" bit.
I am using R2008b.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 7월 16일

0 개 추천

If you set the axis ylabel property explicitly, then the power of 10 will not be printed.
curytick = get(gca, 'YTick');
set(gca, 'YLabel', cellstr(num2str(curytick(:))))
The (:) is important: the ticks are usually a row vector and they need to be a column vector for num2str() to produce the correct output format.

댓글 수: 2

Charles
Charles 2015년 7월 16일
If I change 'YLabel' to 'yticklabel', this works to get rid of overlapping text due to the exponent. I still need to change the figure size when adding the plot title or the title disappears. So my theory on why this is happening is wrong.
In the opening post I should have said the title disappears for ymax < 0.01 - this is still the case.
That's a handy trick for forcing a column vector...
Walter Roberson
Walter Roberson 2015년 7월 16일
Yes, sorry, should have been YTickLabel

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2015년 7월 15일

댓글:

2015년 7월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by