简体   繁体   English

尝试为变量绘制ecdf时出现“ plot.new尚未被调用”警告错误

[英]Warning error of “plot.new has not been called yet” when attempting to plot ecdf for a variable

I am having difficulty plotting an ECDF function for a variable. 我在为变量绘制ECDF函数时遇到困难。 The simple code below provides an example; 下面的简单代码提供了一个示例;

A = rnorm(100)
plot(ecdf(A),
     abline(v=c(-1,1,1.5)))

When I attempt to plot the function with vertical lines the warning message 当我尝试用垂直线绘制函数时,警告消息

Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) : int_abline中的错误(a = a,b = b,h = h,v = v,untf = untf,...):
plot.new has not been called yet plot.new尚未被调用

appears. 出现。

I have searched a number of sources but I have not been able to identify what mistake I am making. 我已经搜索了许多资源,但无法确定自己在犯什么错误。 If anyone could provide information on how to plot these ecdf plots and then add vertical lines I would greatly appreciate it. 如果有人可以提供有关如何绘制这些ecdf图的信息,然后添加垂直线,我将不胜感激。

Thanks. 谢谢。

Everything is correct except that you first have to plot the graph 一切都正确,除了您首先必须绘制图形

plot(ecdf(A))

And then you can add the abline . 然后可以添加abline As Roland said, abline is not a function of plot (in contrast to ggplot2 ) 正如Roland所说的, abline不是plot的函数(与ggplot2相反)

abline(v=c(-1,1,1.5)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM