情节。新的还没有被调用。

时间:2023-01-02 23:59:08

Why does this happen?

这为什么会发生?

plot(x,y)
yx.lm <- lm(y ~ x)
lines(x, predict(yx.lm), col="red")

Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet

错误在plot.xy(xy。coords(x, y), type = type,…):plot。新的还没有被调用。

6 个解决方案

#1


23  

Some action, very possibly not represented in the visible code, has closed the interactive screen device. It could be done either by a "click" on a close-button. (Could also be done by an extra dev.off() when plotting to a file-graphics device. This may happen if you paste in a mult-line plotting command that has a dev,off() at the end of it but errors out at the opening of the external device but then has hte dev.off() on a separate line so it accidentally closes the interactive device).

一些操作,很可能不在可见代码中表示,已经关闭了交互式屏幕设备。它可以通过“点击”关闭按钮来完成。当绘图到文件-图形设备时,也可以通过额外的dev.off()来完成。这可能会发生,如果你粘贴一个有一个dev,off()在末尾,但是在外部设备打开时出现错误,然后在一个单独的行上有hte dev.off(),所以它不小心关闭了交互设备。

Some (most?) R implementations will start up a screen graphics device open automatically, but if you close it down, you then need to re-initialize it. On Windows that might be window(); on a Mac, quartz(); and on a linux box, x11(). You also may need to issue a plot.new() command. I just follow orders. When I get that error I issue plot.new() and if I don't see a plot window, I issue quartz() as well. I then start over from the beginning with a new plot(., ., ...) command and any further additions to that plot screen image.

一些(?)R实现将启动一个自动打开的屏幕图形设备,但如果您关闭它,则需要重新初始化它。在可能是窗口的窗口();在Mac、石英();在linux box上,x11()。您还可能需要发出一个plot.new()命令。我只是服从命令。当我得到这个错误时,我就会发出plot.new(),如果我没有看到一个plot窗口,我也会发出quartz()。然后我从一开始就有一个新的情节。命令和任何进一步添加到该绘图屏幕图像。

#2


5  

In my case, I was trying to call plot(x, y) and lines(x, predict(yx.lm), col="red") in two separate chunks in Rmarkdown file. It worked without problems when running chunk by chunk, but the corresponding document wouldn't knit. After I moved all plotting calls within one chunk, problem was resolved.

在我的例子中,我尝试调用plot(x, y)和lines(x,预测(yx.lm), col="red")在Rmarkdown文件中的两个单独的块中。它在运行块时没有问题,但是相应的文档不会编织。在我移动了所有的绘图调用后,问题就解决了。

#3


1  

I had the same problem... my problem was that I was closing my quartz window after plot(x,y). Once I kept it open, the lines that previously resulted in errors just added things to my plot (like they were supposed to). Hopefully this might help some people who arrive at this page.

我有同样的问题……我的问题是,我正在关闭我的石英窗(x,y)。一旦我把它打开,那些之前导致错误的代码就会把事情添加到我的情节中(就像他们应该做的那样)。希望这能帮助到这一页的人。

#4


1  

As a newbie, I faced the same 'problem'.

作为一个新手,我面临着同样的“问题”。

In newbie terms : when you call plot(), the graph window gets the focus and you cannot enter further commands into R. That is when you conclude that you must close the graph window to return to R. However, some commands, like identify(), act on open/active graph windows. When identify() cannot find an open/active graph window, it gives this error message.

在newbie术语中:当您调用plot()时,图形窗口会得到焦点,您不能将进一步的命令输入到r中,也就是说,您必须关闭图形窗口才能返回r。当标识()无法找到打开/活动的图形窗口时,它会给出这个错误消息。

However, you can simply click on the R window without closing the graph window. Then you can type more commands at the R prompt, like identify() etc.

但是,您可以简单地单击R窗口而不关闭图形窗口。然后您可以在R提示符中键入更多的命令,比如identify()等。

#5


0  

If someone is using print function (for example, with mtext), then firstly depict a null plot:

如果有人使用打印函数(例如,使用mtext),则首先描述一个空图:

plot(0,type='n',axes=FALSE,ann=FALSE)

and then print with newpage = F

然后用newpage = F打印。

print(data, newpage = F)

#6


0  

plot.new() error occurs when only part of the function is ran.

当只运行部分函数时,会发生新的()错误。

Please find the attachment for an example to correct error With error....When abline is ran without plot() above 情节。新的还没有被调用。 Error-free ...When both plot and abline ran together 情节。新的还没有被调用。

请查收附件为例用错误来纠正错误....当abline在没有错误的情况下运行时…当情节和abline一起运行时。

#1


23  

Some action, very possibly not represented in the visible code, has closed the interactive screen device. It could be done either by a "click" on a close-button. (Could also be done by an extra dev.off() when plotting to a file-graphics device. This may happen if you paste in a mult-line plotting command that has a dev,off() at the end of it but errors out at the opening of the external device but then has hte dev.off() on a separate line so it accidentally closes the interactive device).

一些操作,很可能不在可见代码中表示,已经关闭了交互式屏幕设备。它可以通过“点击”关闭按钮来完成。当绘图到文件-图形设备时,也可以通过额外的dev.off()来完成。这可能会发生,如果你粘贴一个有一个dev,off()在末尾,但是在外部设备打开时出现错误,然后在一个单独的行上有hte dev.off(),所以它不小心关闭了交互设备。

Some (most?) R implementations will start up a screen graphics device open automatically, but if you close it down, you then need to re-initialize it. On Windows that might be window(); on a Mac, quartz(); and on a linux box, x11(). You also may need to issue a plot.new() command. I just follow orders. When I get that error I issue plot.new() and if I don't see a plot window, I issue quartz() as well. I then start over from the beginning with a new plot(., ., ...) command and any further additions to that plot screen image.

一些(?)R实现将启动一个自动打开的屏幕图形设备,但如果您关闭它,则需要重新初始化它。在可能是窗口的窗口();在Mac、石英();在linux box上,x11()。您还可能需要发出一个plot.new()命令。我只是服从命令。当我得到这个错误时,我就会发出plot.new(),如果我没有看到一个plot窗口,我也会发出quartz()。然后我从一开始就有一个新的情节。命令和任何进一步添加到该绘图屏幕图像。

#2


5  

In my case, I was trying to call plot(x, y) and lines(x, predict(yx.lm), col="red") in two separate chunks in Rmarkdown file. It worked without problems when running chunk by chunk, but the corresponding document wouldn't knit. After I moved all plotting calls within one chunk, problem was resolved.

在我的例子中,我尝试调用plot(x, y)和lines(x,预测(yx.lm), col="red")在Rmarkdown文件中的两个单独的块中。它在运行块时没有问题,但是相应的文档不会编织。在我移动了所有的绘图调用后,问题就解决了。

#3


1  

I had the same problem... my problem was that I was closing my quartz window after plot(x,y). Once I kept it open, the lines that previously resulted in errors just added things to my plot (like they were supposed to). Hopefully this might help some people who arrive at this page.

我有同样的问题……我的问题是,我正在关闭我的石英窗(x,y)。一旦我把它打开,那些之前导致错误的代码就会把事情添加到我的情节中(就像他们应该做的那样)。希望这能帮助到这一页的人。

#4


1  

As a newbie, I faced the same 'problem'.

作为一个新手,我面临着同样的“问题”。

In newbie terms : when you call plot(), the graph window gets the focus and you cannot enter further commands into R. That is when you conclude that you must close the graph window to return to R. However, some commands, like identify(), act on open/active graph windows. When identify() cannot find an open/active graph window, it gives this error message.

在newbie术语中:当您调用plot()时,图形窗口会得到焦点,您不能将进一步的命令输入到r中,也就是说,您必须关闭图形窗口才能返回r。当标识()无法找到打开/活动的图形窗口时,它会给出这个错误消息。

However, you can simply click on the R window without closing the graph window. Then you can type more commands at the R prompt, like identify() etc.

但是,您可以简单地单击R窗口而不关闭图形窗口。然后您可以在R提示符中键入更多的命令,比如identify()等。

#5


0  

If someone is using print function (for example, with mtext), then firstly depict a null plot:

如果有人使用打印函数(例如,使用mtext),则首先描述一个空图:

plot(0,type='n',axes=FALSE,ann=FALSE)

and then print with newpage = F

然后用newpage = F打印。

print(data, newpage = F)

#6


0  

plot.new() error occurs when only part of the function is ran.

当只运行部分函数时,会发生新的()错误。

Please find the attachment for an example to correct error With error....When abline is ran without plot() above 情节。新的还没有被调用。 Error-free ...When both plot and abline ran together 情节。新的还没有被调用。

请查收附件为例用错误来纠正错误....当abline在没有错误的情况下运行时…当情节和abline一起运行时。