为什么R中不断发生plot.window()错误?

时间:2019-03-12 17:25:02

标签: r loops plot

此R代码可绘制我的值

density = sim@n[150,,] - simnormal@n[150,,]
plot(x=simnormal@params@w, y=abs(density), log="xy", type="n", xlab = "Size (g)", ylab="Biomass Density")
lines(x=simnormal@params@w, y=abs(density))

我想创建一个循环以在每个时间步都重新绘制图形,

for (i in 1:150){
    density = sim@n[i,,] - simnormal@n[i,,]
    plot(x=simnormal@params@w, y=abs(density), log="xy", type="n", xlab = "Size (g)", ylab="Biomass Density")
    lines(x=simnormal@params@w, y=abs(density))
    Sys.sleep(0.5)
    }

但是会出现此错误

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : 100 y values <= 0 omitted from logarithmic plot
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf

为什么会这样?

任何帮助将不胜感激!

本。

0 个答案:

没有答案