Increase outer position width while keep inner position unchanged

조회 수: 8 (최근 30일)
Frank Zhao
Frank Zhao 2021년 12월 18일
댓글: Star Strider 2021년 12월 18일
How can I make a matlab figure wider so I can place legends (there're 11) outside drawing box so legends do not block plots? Specifically, make the right gray area wider and keep everything else unchanged.

채택된 답변

Star Strider
Star Strider 2021년 12월 18일
I am not absolutely certain what the desired result is, however here is an illustration (although the online Run feature is not the best place to demonstrate it, since the plot areas are constricted, so experiment offline to get the best results) —
x = 1:0.1:10;
y = randn(size(x));
figure
plot(x,y)
grid
legend('y', 'Location','eastoutside')
title('Original')
figure
plot(x,y)
grid
legend('y', 'Location','eastoutside')
title('Repositioning Width')
% Fg = gcf;
% fpos = Fg.Position
% Fg.Position = fpos + [0 0 -50 0];
Ax = gca;
aipos = Ax.InnerPosition
aipos = 1×4
0.1125 0.1100 0.6706 0.8150
Ax.InnerPosition = aipos + [0 0 -0.1 0];
aopos = Ax.OuterPosition
aopos = 1×4
0.0394 0 0.5623 1.0000
Ax.OuterPosition = aopos + [0 0 0.3 0];
.
  댓글 수: 2
Frank Zhao
Frank Zhao 2021년 12월 18일
Exactly what I'm looking for. Thanks.
Star Strider
Star Strider 2021년 12월 18일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by