Avoid plot title superimposing axis

21 views (last 30 days)
When I plot I obtain this:
.
How can I easily avoid the title superimposing the x10^(-3) by placing any of them in a better position? Tried changing the "Position" argument of the function title() (which has the behavior of the function text()) but I don't know how to put it to work properly since I end up putting titles all over the place but not just increasing its height a bit with respect to the plot. I'd really appreciate your help. Thank you!

Accepted Answer

Cam Salzberger
Cam Salzberger on 19 Nov 2021
What are you using to position the title so that it comes close to the axes labels there? By default, the title will be center-aligned, so it shouldn't come close. When I use left alignment, the title moves up automatically to get out of the way of the "x10^y":
figure
hAx = axes;
plot(hAx, 10000+rand(10,1))
title(hAx, 'Testing title')
hAx.TitleHorizontalAlignment = 'left';
I guess if it's a really long title, it will get in the way even when center-aligned:
figure
hAx = axes;
plot(hAx, 10000+rand(10,1))
title(hAx, 'Testing really really really really really really really long title')
In that case, you could just make a whitespace sub-title to artificially bump it up. Probably much easier than playing around with position.
figure
hAx = axes;
plot(hAx, 10000+rand(10,1))
title(hAx, 'Testing really really really really really really really long title',' ')
-Cam

More Answers (0)

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!