Azzera filtri
Azzera filtri

Customizing location of plot on figure

41 visualizzazioni (ultimi 30 giorni)
newbie9
newbie9 il 28 Ago 2019
Commentato: newbie9 il 28 Ago 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])

Risposta accettata

Adam Danz
Adam Danz il 28 Ago 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%

Più risposte (0)

Categorie

Scopri di più su Data Distribution Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by