weixin_43088678 2020-02-07 09:34 采纳率: 0%
浏览 1310
已结题

r语言 legend 不显示也不报错如何修改让它显示出来

# Set up our time increment and our vector (array) of x (time) values
deltaX = 1              # years
maxX = 100             # years
x = seq(0,maxX,deltaX)  # years
# Annual growth rate of the investment
r = 0.15
c = 0.08
# A vector to hold the value of the investment
P = vector(length=length(x)) 
# Initial value of the investment
P[1] = 400
P_Max = 5000

# no fishing
for (i in 2:length(x)) {
  P[i] = P[i-deltaX] + r*deltaX*(1-P[i-deltaX]/P_Max)*P[i-deltaX]
}
plot(x = x, y = P, type = "l", xlab="Time (years)",ylab="number of fish",col="green")

# before
for (i in 2:length(x)) {
  P_e  = P[i-deltaX]*(1-c)
  P[i] = P_e + r*deltaX*(1-P_e/P_Max)*P_e
}
lines(x = x, y = P, type = "l",col="red")

# after
for (i in 2:length(x)) {
  P[i] = P[i-deltaX] + r*deltaX*(1-P[i-deltaX]/P_Max)*P[i-deltaX]
  P[i] = P[i]*(1-c)
}
lines(x = x, y = P, type = "l", col="blue")

legend(x=1,y=95,legend = c("No fishing","Before fishing","After fishing")
       ,col=c("green","red","blue"),lty=1)


不知道为什么 legend 显示不出来请帮助解决一下

  • 写回答

1条回答 默认 最新

  • dabocaiqq 2020-02-08 11:17
    关注
    评论

报告相同问题?

悬赏问题

  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗