creating legend with only string

조회 수: 19 (최근 30일)
sermet
sermet 2016년 8월 11일
댓글: Lina KORONFEL 2020년 7월 14일
x=rand(10,1);
h_x=histfit(x);
title('error');
xlabel('north (cm)')
ylabel('Number of Measurement')
mean_x=mean(x);
h_x = legend([':mean (cm)=' num2str(mean_x)], 'Location','NorthEast');
How can I delete the blue box left near to "mean (cm)=" string in figure to display only string?

채택된 답변

Pham Dang
Pham Dang 2016년 8월 11일
Hi, you should consider using the annotation command. Add these commands after yours :
annotation('textbox',get(h_x,'Position'),'String',['mean (cm)=' num2str(mean_x)])
legend('toggle')
The first command places the text box at the same position of the legend ; the second hides the legend.
  댓글 수: 2
RG
RG 2019년 2월 1일
Is there a way jus to remove the legend labels but keep the legend text? (remove legend colored lines and other labels).
The annotation box creates a string, while in the legend I wand it to be number of rows. Also the font in annotation is huge compared to the whole figure.
Thanks.
Lina KORONFEL
Lina KORONFEL 2020년 7월 14일
Is this question answered?

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

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