Ensure x label never cut off
Show older comments
I have a bar plot with some x labels that can be fairly lengthy (rotated vertically with rotateticklabel). If left on its own, Matlab cuts off the x labels.
How can I set the figure to "squeeze" the bars so that all of the labels are visible?
Accepted Answer
More Answers (1)
Tilen Thaler
on 20 Feb 2013
Dear Mr. Umpfenbach,
There is another method which mingles with Position and OuterPosition in the active axes.
For more details on the Position and OuterPosition axes properties please check Matlab help. But to summarize, here is a sample code:
% get current (active) axes property
get(gca,'OuterPosition')
If your label is cut off one of the elements of the four-element vector OuterPosition = [left bottom width height] should be modified. If your x label is cut off, then perhaps element bottom is too low. Increase it:
set(gca,'OuterPosition',[left bottom + 0.1 width height])
Note that the vector is in normalized units but you may change that to suit your needs.
Perhaps it might happen that title gets cut off in the process. In this case increase height as well.
1 Comment
Opt User
on 12 Feb 2018
This does not work for me, since it crops my figure on top.
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!