【问题标题】:Short legend height in rastervis plot of categorical raster分类栅格的 rastervis 图中的短图例高度
【发布时间】:2017-11-02 23:44:37
【问题描述】:

在使用 levelplot 绘制分类栅格地图时,例如 Josh O'Brien 的答案Legend of a raster map with categorical data, 图例高度总是变短。有没有办法将图例高度调整为与绘图窗口相同的高度?

【问题讨论】:

    标签: raster levelplot rastervis


    【解决方案1】:

    您可以通过将colorkey=list(height=1) 传递给 levelplot 函数来设置图例高度。

    library(raster)
    library(rasterVis)
    
    ## Example data
    r <- raster(ncol=4, nrow=2)
    r[] <- sample(1:4, size=ncell(r), replace=TRUE)
    r <- as.factor(r)
    
    ## Add a landcover column to the Raster Attribute Table
    rat <- levels(r)[[1]]
    rat[["landcover"]] <- c("land","ocean/lake", "rivers","water bodies")
    levels(r) <- rat
    
    ## Plot
    levelplot(r, colorkey=list(height=1), col.regions=rev(terrain.colors(4)), xlab="", ylab="")
    

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 2013-10-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 2018-06-24
      相关资源
      最近更新 更多