Resizing Figure to Make Room for Title without Resizing Plot

43 vues (au cours des 30 derniers jours)
Yugarshi Mondal
Yugarshi Mondal le 18 Fév 2021
Modifié(e) : dpb le 27 Fév 2021
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!

Réponse acceptée

dpb
dpb le 18 Fév 2021
Modifié(e) : dpb le 18 Fév 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 commentaires
dpb
dpb le 27 Fév 2021
Modifié(e) : dpb le 27 Fév 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...
Yugarshi Mondal
Yugarshi Mondal le 27 Fév 2021
Modifié(e) : Yugarshi Mondal le 27 Fév 2021
Thanks for the explanation!
More than that, I was dumping insets into the figure. The insets were causing additinal consternation -- but they were fixed by modifying the line you mentioned along with the fourth line in the loop!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by