Customizing location of plot on figure

130 visualizaciones (últimos 30 días)
newbie9
newbie9 el 28 de Ag. de 2019
Comentada: newbie9 el 28 de Ag. de 2019
How can I set a plot to be in the center of a figure, while controlling the width? The problem I ham having is that my heatmap is way too wide and aligned at the bottom left of the page. I want to force it to by 50% narrower. The height will change depending on the number of columns, so I dont want to edit the x, y, or height info.
positioning = get(gca, 'position');
set(gca, 'position', [positioning(1) positioning(2) positioning(3)/4 positioning(4)/2]) %x y width height
h2 = gcf;
set(h2, 'PaperPositionMode', 'auto');
set(h2, 'PaperOrientation', 'portrait');
set(h2, 'PaperUnits', 'inches', 'PaperPosition', [0, 0, 8.5, 11])

Respuesta aceptada

Adam Danz
Adam Danz el 28 de Ag. de 2019
Here's how to reduce the width of an heatmap to 50% and to center it on the figure. If you only want to reduce it to 50% and not change its lateral position, skip the 2nd line of code.
h = heatmap(. . .); % get the heatmap handle
h.Position(1) = h.Position(1) + (h.Position(3)/4); % move so that it will be centered
h.Position(3) = h.Position(3)/2; % reduce width to 50%

Más respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by