使用RandomFields软件包在空白图中绘制随机高斯场的实现。为什么?

使用RandomFields软件包在空白图中绘制随机高斯场的实现。为什么?,r,random,plot,gaussian,R,Random,Plot,Gaussian,出于某种原因,当我尝试使用plot()函数来可视化随机化字段包中的RFsimulate()函数的输出时,输出总是一个空图 我只是使用帮助文件中包含的示例代码: ## first let us look at the list of implemented models RFgetModelNames(type="positive definite", domain="single variable", iso="isotropic") ## our choic

出于某种原因,当我尝试使用
plot()
函数来可视化
随机化字段
包中的
RFsimulate()
函数的输出时,输出总是一个空图

我只是使用帮助文件中包含的示例代码:

## first let us look at the list of implemented models
RFgetModelNames(type="positive definite", domain="single variable",
                iso="isotropic") 

## our choice is the exponential model;
## the model includes nugget effect and the mean:
model <- RMexp(var=5, scale=10) + # with variance 4 and scale 10
  RMnugget(var=1) + # nugget
  RMtrend(mean=0.5) # and mean

## define the locations:
from <- 0
to <- 20
x.seq <- seq(from, to, length=200) 
y.seq <- seq(from, to, length=200)

simu <- RFsimulate(model=model, x=x.seq, y=y.seq)
str(simu)
。。。所以数据是模拟的,但当我打电话

plot(simu)
我的结局是这样的:


谁能告诉我这里发生了什么

我会将对象强制返回到
sp
SpatialGridDataFrame
并绘制,因为
RandomFields
会在这个S4类周围创建一个包装:

sgdf = sp::SpatialGridDataFrame(simu@grid, simu@data, simu@proj4string)
sp::plot(sgdf)
此外,还可以使用标准图形库强制生成矩阵和打印:

graphics::image(as.matrix(simu))
奇怪的是,将其转换为
SpatialGridDataFrame
需要在打印之前进行翻转和转置:

graphics::image(t(apply(as.matrix(sgdf), 1, rev)))
显然,它们在内部有点不一致。最简单的解决方案是将
simu
转换为
graster
plot

r = raster::raster(simu)
raster::plot(r)

你在用rstudio吗?我只有Rstudio有类似的问题。执行
x11();绘图(simu)
打开一个新窗口并正确绘制随机场。我在Rstudio中遇到了完全相同的问题@X光头解决方案可行,但并不理想。你知道为什么会这样吗?
r = raster::raster(simu)
raster::plot(r)