Resize plot to fit text
显示 更早的评论
Is it possible to resize the y-axis automatically, so that my text always fits in the plot.
(as far as I can see, it is not clearly possible by using the "axis" and "ylim" functions)

3 个评论
Walter Roberson
2019-12-9
Yes, it is possible. However, it is a nuisance at the best of times, and gets to be a pain if any text anywhere on your plot is using tex or latex interpreter.
It is a lot easier to just examine the current ylim() and make it a bit larger, such as giving an extra 5%. This simplistic solution does not take into account that there might be existing text that is notably off-screen: it makes no attempt to locate the text objects and figure out if they are visible and fontsize and vertical alignment and complications caused by tex or latex interpreters... but for the case you give the example for, making ylim just a bit larger is very likely to be good enough.
Davor Pavlovski
2019-12-9
Walter Roberson
2019-12-9
The only methods I can think of are not clean.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Object Properties 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
