image.plot 不会创建新图像 [英] image.plot does not create new image

查看:48
本文介绍了image.plot 不会创建新图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是生成图像图的代码示例.但出于某种原因,当我重新运行它时,没有创建新图像,但它覆盖了现有的绘图.但是我希望它创建一个新图像,当然因为它有一个特定的参数add"来指定它必须添加到现有的绘图中(但默认值为 FALSE).

Here is a sample of code that produces a image plot. But for some reason, when I re-run it, no new image is created but it overlays the existing plot. However I expect it to create a new image, certainly as it has a specific parameter 'add' to specify that it has to be added to the existing plot (but default value is FALSE).

有人知道这里发生了什么吗?

Does anybody know what is going on here?

require(fields)

mat <- matrix(runif(5*5), ncol=5) 

mat[1,3] <- NA

image.plot(seq(1,5,1),seq(1,5,1), mat, col = tim.colors(64), legend.only=TRUE)
par(oma=c(0,0,0,6))
par(new = TRUE)
image(seq(1,5,1),seq(1,5,1),matrix(1,5,5), col = gray(0.8), xlab = "", ylab = "", axes = F)
par(new = TRUE)
image(seq(1,5,1),seq(1,5,1),mat, xlab="Hour of the Day", ylab = "Day of the Week", col = tim.colors(64), axes = F)
par(oma=c(0,0,0,0))

编辑我对设备等不太了解.但是我确实知道(并且我在 RStudio 中工作),例如,当我首先执行 plot(1:10) 然后是 plot(10:1) 清除图形窗口并显示第二个图形而不将其添加到第一个图形(在 RStudio 中,您当然还有其他功能,您也可以浏览以前的图形,但如果我也这样做在普通的 R 控制台中,调用第二个绘图时会清除绘图窗口).而正是我想要的,我只是希望在我第二次调用 image.plot 时清除图形窗口,而不是覆盖上一次调用 image.plot 时的图像.>

EDIT I don't know much about devices etc. But I do know that (and I am working in RStudio) when I do eg first plot(1:10) and then plot(10:1) that the figure window is cleared and the second plot is shown without being added to the first one (in RStudio you have off course the additional functionality that you can also browse your previous figures, but if I do the same in a plain R console, the plotting window is cleared when the second plot is called). And that is what I want, I just expect that the figure window is cleared when I call image.plot a second time, instead of overlaying the image from the previous time I called image.plot.

推荐答案

您注意到 par 的new"参数的含义发生了奇怪的逆转.这是帮助页面说明:

You are noticing the odd reversal in meaning for the "new" parameter to par. Here's the help page description:

logical, defaulting to FALSE. If set to TRUE, the next high-level plotting command 
(actually plot.new) should not clean the frame before drawing as if it were on a new 
device. It is an error (ignored with a warning) to try to use new = TRUE on a device 
that does not currently contain a high-level plot.

这篇关于image.plot 不会创建新图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆