spplot {sp}
在 R 中使用时,一切正常。然而,当我在一个函数中使用它时,spplot
似乎什么都不做。
这是我打算做的一个例子:
A)这有效:
#load packages
require(gplots)
require(sp)
require(profvis)
#create spatial polygon with categories-attribute
grd <- GridTopology(c(1,1), c(1,1), c(10,10))
polys <- as.SpatialPolygons.GridTopology(grd)
myAttribute <- c(rep("A",12), rep("B",59), rep("C",29))
df <- data.frame(myAttribute=myAttribute, row.names=row.names(polys))
polygons(df) <- polys
#plot polygons by attribute
spplot(df["myAttribute"], col.regions=c("green","yellow","blue"),oma=c(4,4,4,4))
test <- function (){
textplot("text to appear", halign="right", mar=c(4,4,4,4), col="black")
pause(1)
spplot(df["myAttribute"], col.regions=c("green","yellow","blue"),oma=c(4,4,4,4))
}
test()
C) 但是,当spplot
函数内的任何内容紧随其后时,将spplot
被跳过。在下一个图被绘制之前,图应该出现 5 秒。然而,情节根本没有绘制。
test <- function (){
textplot("text to appear", halign="right", mar=c(4,4,4,4), col="black")
pause(1)
spplot(df["myAttribute"], col.regions=c("green","yellow","blue"),oma=c(4,4,4,4))
pause(5)
plot(df)
}
test()
这是一个已知的问题spplot
吗?有什么修复方法吗?
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句