Resizing Figure to Make Room for Title without Resizing Plot
38 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
dpb
am 18 Feb. 2021
Bearbeitet: dpb
am 18 Feb. 2021
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 Kommentare
dpb
am 27 Feb. 2021
Bearbeitet: dpb
am 27 Feb. 2021
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...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!