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

1 次查看(过去 30 天)
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