【问题标题】:Move the position of colorbar/ colorkeys in levelplot在 levelplot 中移动颜色条/颜色键的位置
【发布时间】:2020-05-05 09:23:42
【问题描述】:

我已经使用函数'levelplot'脚本绘制了一堆栅格,如下所示:

library(raster)
library(rasterVis)
ras <- list.files("/filepath/", pattern = "\\.tif$", full=TRUE)
s <- stack(ras)
> levelplot(s, colorkey = list(space ="bottom",height=1, width=1),
names.attr=c("2011","2012","2013", "2014")))

Figure of Levelplot

绘图的问题是 x 轴标签“经度”的标签与绘图的颜色条/颜色键重叠。是否可以将颜色键的位置移动到标签“经度”下方一点?

谢谢

【问题讨论】:

    标签: r plot raster levelplot


    【解决方案1】:

    您可以使用xlab 列表中的vjust 参数进行调整...

    levelplot(s, colorkey = list(space = "bottom", height = 1, width = 1),
                names.attr = c("2011", "2012", "2013", "2014"),
                xlab = list(label = "Longitude", vjust = -.2)))
    

    之前(使用虚拟数据):

    之后:

    【讨论】:

    • 谢谢,效果很好。我不能赞成您的回答,因为我的声誉少于 15 个。我是 SO.. 的新手。当我超过 15 岁时,我会恢复投票:)
    【解决方案2】:

    @Khaynes 回答问题:

    levelplot(s, colorkey = list(space = "bottom", height = 1, width = 1),
                names.attr = c("2011", "2012", "2013", "2014"),
                xlab = list(label = "Longitude", vjust = -.2)))
    

    结果-> 感谢@Khaynes

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-29
    相关资源
    最近更新 更多