HELP ON PLOT LEGEND, ERROR APPEARED for the third run!!

조회 수: 27 (최근 30일)
Samantha Chong
Samantha Chong 2015년 11월 6일
답변: Thorsten 2015년 11월 6일
Hi guys, I'm having trouble trying to add multiple entries on my legend, it was working perfectly fine during the first and second run (I'm so regretful for not saving it :(. However, on the third run, error turned up as shown below, I've attached Figure which was created when there's no legend, and the Figure 2 is when I've added multiple entries on the legend as well as fixing the position of my legend (I'm wondering if it's something to do with the matlab legend tool??):
legend('measurement','HYCOM','run07','Location','northwest') %This is the legend line added to my code for the 1st plot in Figure 1 legend('measurement','HYCOM','run07','Location','southwest'); %This is the legend line added to my code for the 2nd plot in Figure 1
Figure 1 (Without Legend)
Figure 2 (With Legend)
Property name already in use by this class or one of its superclasses.
Error in scribe.legend/init (line 71) l = schema.prop(handle(fig),'ScribeLegendListeners','MATLAB array');
Error in scribe.legend (line 122) h.init();
Error in legend>make_legend (line 387) lh=scribe.legend(ha,orient,location,position,children,listen,strings,propargs{:});
Error in legend (line 285) [h,msg] = make_legend(ha,varargin(arg:end));
Error in SamMainPlotCTD (line 42) legend('measurement','HYCOM','run07');||||

채택된 답변

Thorsten
Thorsten 2015년 11월 6일
Use handles:
h(1) = subplot(1,2,1), plot(rand(10,3))
h(2)= subplot(1,2,2), plot(rand(10,3))
legend(h(1), {'measurement','HYCOM','run07'},'Location','northwest')
legend(h(2), {'measurement','HYCOM','run07'},'Location','southwest')

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