【问题标题】:How to remove background gray color when using gplot method in Rastervis?在 Rastervis 中使用 gplot 方法时如何去除背景灰色?
【发布时间】:2014-12-02 16:44:39
【问题描述】:

有谁知道,在 Rastervis 中使用 gplot 方法时如何去除背景灰色?我已经尝试移除主题颜色,但没有成功。

r <- raster(system.file("external/test.grd", package="raster"))
s <- stack(r, r*2)
names(s) <- c('meuse', 'meuse x 2')

library(ggplot2)

theme_set(theme_bw())
gplot(s) + geom_tile(aes(fill = value)) +
    facet_wrap(~ variable) +
    scale_fill_gradient(low = 'white', high = 'blue') +
    coord_equal() +
    theme(
            plot.background = element_blank()
            ,panel.grid.major = element_blank()
            ,panel.grid.minor = element_blank()
            ,panel.border = element_blank()
            ,panel.background = element_blank())

【问题讨论】:

  • 看看添加 theme_bw() 是否有效
  • 已经设置为theme_set(theme_bw()),但是没有用。灰色似乎来自栅格数据。
  • 你可以试试:gplot(s) + geom_tile(aes(fill = value)) + theme_bw() + ...

标签: r ggplot2 r-raster rastervis


【解决方案1】:

按照@Bingwei 提供的链接,我发现使用scale_fill_gradient(low = 'white', high = 'blue', na.value=NA)) 对我有用。注意na.value=NA 而不是na.value="white"

【讨论】:

    【解决方案2】:

    我已经从 rasterVis 的作者那里得到了答案 https://github.com/oscarperpinan/rastervis/issues/13#comments

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-17
      • 2021-11-16
      • 1970-01-01
      • 2019-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-15
      相关资源
      最近更新 更多