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.

Réponses (1)

Walter Roberson
Walter Roberson le 16 Juil 2015

0 votes

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 commentaires

Charles
Charles le 16 Juil 2015
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 le 16 Juil 2015
Yes, sorry, should have been YTickLabel

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics dans Centre d'aide et File Exchange

Question posée :

le 15 Juil 2015

Commenté :

le 16 Juil 2015

Community Treasure Hunt

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

Start Hunting!

Translated by