r - “plot.xy(xy.coords(x, y), type = type, ...) 中的错误:尚未调用 plot.new”
问题描述
当我想要线时,R中的线函数会出现一些不寻常的错误
lines(soy$Year,ci_soy[,1],col='black',lwd=3)
lines(soy$Year,ci_soy[,1],type="l", col="green", lwd=3,xlab="Year", ylab="bu_acre")
plot(soy$Year,ci_soy[,1],type="l", col="green", lwd=3,xlab="Year", ylab="bu_acre")
解决方案
简单的解决方案应该是:首先调用这行代码
plot(mtcars$disp,ci_mtcars[,1],type="l", col="green", lwd=3,xlab="disp", ylab="bu_acre")
说明:在基础 R 中,首先您必须开始一个绘图plot
以生成绘图。在此图中,lines
可以添加您的功能。看我的例子:
# without plot
lines(iris$Sepal.Length, col='black',lwd=3)
Output:
error in plot.xy(xy.coords(x, y), type = type, ...) :
plot.new has not been called yet
# with plot
# empty plot frame for lines
plot(1, type="n", xlab="", ylab="", xlim=c(0, 100), ylim=c(0, 10))
lines(iris$Sepal.Length, col='black',lwd=3)
推荐阅读
- html - 编写一个 xpath 来检查两个不同 html 元素中存在的文本
- docker - Docker 镜像拉取错误无效字符
- javascript - 展开运算与打字稿现象
- dart - Dart中的常量变量和常量值有什么区别?
- r - ggplot中的矩阵热图在上下三角形中不一致
- google-app-engine - appcfg 工具关闭后,基于 python2 标准运行时应用程序的谷歌 appengine 遗留服务是否会继续工作?
- python - python在小数点分隔符后显示太多数字
- c++ - 尝试使用 Windows Midi API 时出现 gcc 错误
- r - 你好。我在执行下面的 r 代码以用另一个替换一个列值时陷入困境
- java - springboot+mybatis 多模块项目maven