Resizing Figure to Make Room for Title without Resizing Plot
38 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Yugarshi Mondal
el 18 de Feb. de 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!
0 comentarios
Respuesta aceptada
dpb
el 18 de Feb. de 2021
Editada: dpb
el 18 de Feb. de 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 comentarios
dpb
el 27 de Feb. de 2021
Editada: dpb
el 27 de Feb. de 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...
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!