Customizing location of plot on figure

105 ビュー (過去 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%
  1 件のコメント
newbie9
newbie9 2019 年 8 月 28 日
awesome, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by