필터 지우기
필터 지우기

How to avoid programmatically the data overlapping from legend in plots

조회 수: 15 (최근 30일)
pietro
pietro 2014년 11월 27일
답변: Orion 2014년 11월 27일
Hi all,
I programmatically plot many data as a bar plot. Unfortunately for plots where the last bar is very high legend overlaps the bar. I may do it by setting ylim, but the data ranges may differ of several order of magnitude. Is there any programmatically way to avoid this?
Thank you
best regards
pietro

채택된 답변

Orion
Orion 2014년 11월 27일
2 ways, If you want it inside :
% user defined position (ex : right bottom)
set(hleg1,'Position',[0.7443 0.1782 0.1518 0.1286])
% automatic
set(hleg1,'Location','best')

추가 답변 (1개)

Orion
Orion 2014년 11월 27일
Hi
You could just put the legend outside the axe
figure
x = -pi:pi/20:1;
bar(x,cos(x),'b')
hold on
bar(x,sin(x),'r')
hleg1 = legend('cos_x','sin_x');
pause(1)
set(hleg1,'Location','BestOutside') % legend is outside
see the doc of legend for the different possibble location .
  댓글 수: 1
pietro
pietro 2014년 11월 27일
Hi Orion,
thanks for the kind reply. I knew the option, but I would prefer to place the legend inside to maximize the axes area.

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

카테고리

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