Resizing Legend Box while Exporting in MATLAB Figures

조회 수: 19 (최근 30일)
JPS
JPS 2021년 12월 31일
댓글: Adam Danz 2022년 1월 3일
I want my MATLAB Figure to be resized to inches.
x = 0:0.01:2*pi;
y = sin(x);
z = cos(x);
y2 = sin(2 * x);
z2 = cos(2 * x);
plot(x, y);
hold on
plot(x, z);
plot(x, y2);
plot(x, z2);
hold off
grid on
legend("sin(x)", "cos(x)", "sin(2x)", "cos(2x)", "orientation", "horizontal");
I changed the Height and Width in File > Exports Setup in the Figure Window.
But the problem is the legend box alone does'nt get scaled accordingly. It ackwardly sticks out in the exported image.
Demo_Image
Help me to scale the legend box along with the figure.

답변 (1개)

Sivani Pentapati
Sivani Pentapati 2022년 1월 3일
Hi JPS,
In order to resize the legend based on size of the figure, you can configure the Position property of legned. This lets you customize the location of the legend along with its size.
  댓글 수: 1
Adam Danz
Adam Danz 2022년 1월 3일
Also see the orientation property. A vertical oriented legend may be better suited for your figure. The numcolumns property may also come in handy if you want more than 1 row or column of legend entries.

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by