Resizing Figure to Make Room for Title without Resizing Plot
36 次查看(过去 30 天)
显示 更早的评论
I'm trying to create a figure. I want the plot sizes to remain the same, but I want more room at the top of the figure to display my titles.
How do I accomplish this? I can't simply resize the entire figure, becuase the plot sizes increase too!
0 个评论
采纳的回答
dpb
2021-2-18
编辑:dpb
2021-2-18
hAx=gca;
hAx.Position=hAx.Position.*[1 1 1 0.95];
adjusts the height of axes to be 95% of default/previous height. Adjust to suit; repeat for each axes.
If you have saved all the axes handles, one could do it globally via set(hAx, ...) get() with some machinations.
16 个评论
dpb
2021-2-27
编辑:dpb
2021-2-27
Were so many iterations I'm guessing it is the following line in Q?
hAx(k).Position(2)=hAx(k).Position(2)+hAx(k).Position(4)*0.05;
It's just raising the bottom of the axes a little, adding 5% of the height (the 4th element in position vector) to the second (the bottom location). Remember the position vector is defined as [left bottom width height].
The 5% factor is the complement of the 95% that I used above to reduce the height so the final top location will be almost back to its original location.
In original testing, I didn't see the need to make the adjustment to the bottom position if one reduced the height after creating the labels; then it seemed to adjust the postions adequately for clearance. However, I later discovered behavior is different between creating a new figure and writing into it and in having an existing figure of the same dimensions and rewriting into it, even after one deletes all existing axes from the figure. As noted above, I have no idea why that should be so; clearly something gets munged on internally by the previous plotting that doesn't go back to precisely the same initial conditions as are present when the figure is first created.
It was to fix that last small aberration that I just then raised up the location of the bottom axis a smidge...
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!