相关疑难解决方法(0)

spplot()上的country-labels

我想为spplot()上的区域添加名称标签.

例:

load(url('http://gadm.org/data/rda/FRA_adm0.RData'))
FR <- gadm
FR <- spChFIDs(FR, paste("FR", rownames(FR), sep = "_"))
load(url('http://gadm.org/data/rda/CHE_adm0.RData'))
SW <- gadm
SW <- spChFIDs(SW, paste("SW", rownames(SW), sep = "_"))
load(url('http://gadm.org/data/rda/DEU_adm0.RData'))
GE <- gadm
GE <- spChFIDs(GE, paste("GE", rownames(GE), sep = "_"))

df <- rbind(FR, SW, GE)

## working
plot(df)
text(getSpPPolygonsLabptSlots(df), labels = c("FR", "SW", "GE"))


## not working
spplot(df[1-2,])
text((getSpPPolygonsLabptSlots(df), labels = c("FR", "SW"))
Run Code Online (Sandbox Code Playgroud)

第二个可能因为格子而无法工作!?但是,我需要spplot功能.我如何获得情节上的标签?

graphics maps r lattice

4
推荐指数
2
解决办法
2979
查看次数

如何按地区添加颜色?

数据

代码

    #
    # This is code for mapping of CGE_Morocco results
    #

    # rm(list = ls(all = TRUE)) # don't use this in code that others will copy/paste

    ## Loading packages
    library(rgdal)
    library(plyr)
    library(maps)
    library(maptools)
    library(mapdata)
    library(ggplot2)
    library(RColorBrewer)

    ## Loading shape files administrative coordinates for Morocco maps
    #Morocco <- readOGR(dsn=".", layer="Morocco_adm0")
    MoroccoReg <- readOGR(dsn=".", layer="Morocco_adm1")

    ## Reorder the data in the shapefile based on the regional order
    MoroccoReg <- MoroccoReg[order(MoroccoReg$ID_1), ] 

    ## Add the yield impacts column to …
Run Code Online (Sandbox Code Playgroud)

maps r ggplot2

2
推荐指数
1
解决办法
3418
查看次数

标签 统计

maps ×2

r ×2

ggplot2 ×1

graphics ×1

lattice ×1