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

1 view (last 30 days)
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');||||

Accepted Answer

Thorsten
Thorsten on 6 Nov 2015
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')

More Answers (0)

Community Treasure Hunt

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

Start Hunting!