Plot: legend with spurious entries

4 次查看(过去 30 天)
Stefan Boeters
Stefan Boeters 2016-10-28
评论: KSSV 2016-10-28
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 个评论
KSSV
KSSV 2016-10-28
编辑:KSSV 2016-10-28
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')

请先登录,再进行评论。

回答(1 个)

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

类别

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