Warning when using 'Box','off' in legend and the box of the legends keeps showing!
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad Abouali
el 14 de En. de 2015
Editada: Mohammad Abouali
el 14 de En. de 2015
Does any one know why the following error is generated and the box of the legend is still showing?
x=0:0.1:2*pi;
y1=sin(x);
y2=cos(x);
plot(x,y1);
hold on
plot(x,y2);
axis tight
legend('sin','cos','Location','North','Box','off')
Warning: Ignoring extra legend entries.
> In /Applications/MATLAB_R2014b.app/toolbox/matlab/scribe/private/legendHGUsingMATLABClasses.p>set_children_and_strings at 649
In /Applications/MATLAB_R2014b.app/toolbox/matlab/scribe/private/legendHGUsingMATLABClasses.p>make_legend at 312
In /Applications/MATLAB_R2014b.app/toolbox/matlab/scribe/private/legendHGUsingMATLABClasses.p>legendHGUsingMATLABClasses at 241
In legend at 118
0 comentarios
Respuesta aceptada
Geoff Hayes
el 14 de En. de 2015
Mohammad - the line of code
legend('sin','cos','Location','North','Box','off')
seems to be considering the final two inputs/strings as labels for curves that don't exist. If you just execute the command
h = legend('sin','cos','Location','North')
it works without warning, and moves the legend to the appropriate location.
Glancing at the documentation for legend, there doesn't seem to be an option that allows you to set the curve labels and the box in this manner. There are "signatures" for Location and for Orientation, but when it comes to using the other parameters, the one signature seems to be just
legend(strings,Name,Value)
So if you were to try
legend({'sin','cos'},'Box','off')
then no warning would be generated, but on my version of MATLAB (R2013a), only part of the box is removed. In order to remove all of the box, I either have to do
h = legend('sin','cos','Location','north');
set(h,'boxoff');
or
h = legend('sin','cos','Location','north');
set(h,'box','off');
1 comentario
Mohammad Abouali
el 14 de En. de 2015
Editada: Mohammad Abouali
el 14 de En. de 2015
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!