필터 지우기
필터 지우기

Alignment of the Legend in Matlab Plot Figure

조회 수: 22 (최근 30일)
Kanchibhotla Chandra Sekhar
Kanchibhotla Chandra Sekhar 2014년 4월 16일
댓글: Zoltán Gátmezei 2020년 3월 1일
I am trying to plot a figure with five sets of data with subplot is having individual legend but the problem is axis is getting mismatched when i trying to put the legend of plots having varies length of text.
x = [1:10];
y = 2*x;
z = x+1.25*y;
z1 = z+x;
subplot(4,1,1);
plot(x);
legend('x Variable','Location','NorthEastOutside');
subplot(4,1,2);
plot(y);
legend('y var','Location','NorthEastOutside');
subplot(4,1,3);
plot(z);
legend('z','Location','NorthEastOutside');
subplot(4,1,4);
plot(z1);
legend('z1 point','Location','NorthEastOutside');
When i am trying to plot.. i am getting the Figure like this -
All legends when location is 'NorthEastOutside' [when outside the plot] getting allocated right alignment of the legend. I want the data with equal axes length or left justified legend.
Is it possible to get the data with Left Justified without comprising on the axes length...?

채택된 답변

Kanchibhotla Chandra Sekhar
Kanchibhotla Chandra Sekhar 2014년 4월 21일
x = [1:10];
y = 2*x;
z = x+1.25*y;
z1 = z+x;
h(1)=subplot(4,1,1);
plot(x);
legend('x Variable','Location','NorthEastOutside');
h(2)=subplot(4,1,2);
plot(y);
legend('y var','Location','NorthEastOutside');
h(3)=subplot(4,1,3);
plot(z);
legend('z','Location','NorthEastOutside');
h(4)=subplot(4,1,4);
plot(z1);
legend('z1 point','Location','NorthEastOutside');
m=zeros(length(h),4);
for k=1:length(h)
m(k,:) = get(h(k),'Position');
end
m(:,3) = max(m(:,3));
for k=1:length(h)
set(h(k),'Position',m(k,:));
end
  댓글 수: 2
Jeff Cron
Jeff Cron 2018년 6월 4일
This no longer seems to work in R2018a??
Zoltán Gátmezei
Zoltán Gátmezei 2020년 3월 1일
No longer seems to work in R2019b either

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

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by