Customizing location of plot on figure

조회 수: 56 (최근 30일)
newbie9
newbie9 2019년 8월 28일
댓글: newbie9 2019년 8월 28일
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])

채택된 답변

Adam Danz
Adam Danz 2019년 8월 28일
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%

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by