Plot: legend with spurious entries

10 visualizaciones (últimos 30 días)
Stefan Boeters
Stefan Boeters el 28 de Oct. de 2016
Comentada: KSSV el 28 de Oct. de 2016
When I run the following plotting code:
data = randn(100,1);
plot(data)
hold on;
plot(zeros(100),':','Color',[0.5 0.5 0.5]);
hold off;
legend('Testdata')
legend('Location','north')
I get the following strange result:
Looks like a bug to me. When I delete the last line of code (replacement of the legend), it works well. Do I miss something?
  1 comentario
KSSV
KSSV el 28 de Oct. de 2016
Editada: KSSV el 28 de Oct. de 2016
Me too got same result. This works:
data = randn(100,1);
plot(data)
hold on;
plot(zeros(100),':','Color',[0.5 0.5 0.5]);
hold off;
legend('Testdata','Location','north')

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 28 de Oct. de 2016
I can confirm this behavior with Matlab R2009a: Changing the location afterwards does not work.

Categorías

Más información sobre Legend en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by