图例功能中不显示图例:R

时间:2017-09-27 13:32:55

标签: r plot legend

我试图使用以下代码绘制一个简单的图形;

person5.getAge();

enter image description here

然后我尝试在情节中添加一个图例

plot(y = Et, x = t, type = "l", col = 1,
 xlab = "Time",     ylab= "Equity ($)",
 main = "Figure 1–3: Randomly Generated Equity Curves") 
grid()
abline(h = 10000)
lines(y = Et2, x = t, col = 2)
lines(y = Eb, x = t, col = 8)

我获得的结果如下:

enter image description here

我哪里错了?

编辑1:我重新启动了R studio并重新运行了这些图,得到了以下结果。

enter image description here

编辑2:可重复的代码:

legend(x = "topleft", col = c(1,2,8), lwd = 2, legend = c("Curve 1",
                                                      "Curve 2",
                                                      "SPY"))

上面的代码是我为了生成上面的图而运行的代码。如果您能够运行它并得到相同的错误,请告诉我。

0 个答案:

没有答案