Remove legend box in a plot

조회 수: 192 (최근 30일)
Dommal
Dommal 2016년 7월 5일
댓글: Star Strider 2016년 7월 5일
Hi everyone,
I want to remove legend box, I use:
[hLeg,hObj]=legend([plot2 plot1 plot3 plot4 ],{'experimental data d=3.5','Model 1: d=3.5','Model 2: d=3.5','Model 3: d=3.5'})
set(legend,'Location','NorthWest')
set(legend,'FontSize',12)
axis([5,15,6,7.8])
set(gca,'fontsize',12)
xlabel('Wall thickness [mm]') % x-axis label
ylabel('ln(F_{max,k}) [-]') % y-axis label
box off
set(hLeg,'Visible','off');
set(hObj,'Visible','on');
The legend disappears completely.

채택된 답변

Star Strider
Star Strider 2016년 7월 5일
See the legend documentation for Remove Legend Border.
See if this does what you want:
[hLeg,hObj]=legend([plot2 plot1 plot3 plot4 ],{'experimental data d=3.5','Model 1: d=3.5','Model 2: d=3.5','Model 3: d=3.5'})
set(legend,'Location','NorthWest')
set(legend,'FontSize',12)
axis([5,15,6,7.8])
set(gca,'fontsize',12)
xlabel('Wall thickness [mm]') % x-axis label
ylabel('ln(F_{max,k}) [-]') % y-axis label
legend('boxoff') % <= Change This Line
I can’t run your code, but that should work (in R2016a). If you have a different version, the command to turn the legend box off may be different.
  댓글 수: 2
Dommal
Dommal 2016년 7월 5일
It works! Thank you.
Star Strider
Star Strider 2016년 7월 5일
My pleasure!

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

추가 답변 (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