【发布时间】:2018-05-26 11:06:03
【问题描述】:
我正在使用 R 包 GWmodel。在绘制 GWR 的输出时,我发现自己无法在 ssplot 函数中编辑侧边栏。
我正在使用的几行代码(数据已经在包中)就足够了。你只需要安装GWmodel库:
library(GWmodel)
data("DubVoter")
bw.gwr.1 <- bw.gwr(GenEl2004 ~ DiffAdd + LARent + SC1 + Unempl + LowEduc + Age18_24 + Age25_44 + Age45_64, data = Dub.voter, approach = "CV", kernel = "gaussian", adaptive = FALSE)
gwr.res <- gwr.basic(GenEl2004 ~ DiffAdd + LARent + SC1 + Unempl + LowEduc + Age18_24 + Age25_44 + Age45_64, data = Dub.voter, bw = bw.gwr.1, kernel = "gaussian", adaptive = FALSE, F123.test = TRUE)
Greens <- c("#238B45","#74C476","#BAE4B3","#EDF8E9")
spplot(gwr.res$SDF, "Unempl", cuts = 4, at = c(fivenum(gwr.res$SDF$Unempl)), col.regions = Greens)
结果如下:
正如您在 spplot 函数中看到的,参数 at 的值是 c(fivenum(gwr.res$SDF$Unempl)),对应于最小值、第 1 个四分位数、中位数、第 3 个四分位数、最大值在 gwr.res$SDF$Unempl。查看图表,我们可以看到颜色将此划分为 4 个类(使用参数 cut = 4 at = c(fivenum(gwr.res$SDF$Unempl)))。
我想做的是用调色板编辑侧边栏,并用 c(fivenum(gwr.res$SDF$Unempl)) 中的值添加替换 6,4,2,0,-2 :
-2.427,-0.916,-0。 6.706, -0.494, 7.566
【问题讨论】:
标签: r plot choropleth gwmodel