【问题标题】:Annotation_raster does not work with scale_x_reverseAnnotation_raster 不适用于 scale_x_reverse
【发布时间】:2012-03-21 10:42:55
【问题描述】:

我正在创建以光栅文件为背景的地理地图。为了更好地显示,我想将其中一些向侧面翻转(即,使北指向左侧,而不是向上)。这意味着我必须反转 x 轴(除了翻转 x 和 y),否则数据显示错误(镜像)。

它适用于 geom_tile,但当然这很慢,尤其是在做构面时。 所以,我想使用annotation_raster。这也很好,但只有在我反转 x 轴之前。然后就不再显示了。

此外,我怀疑这可能是相关的:切换 xmin 和 xmax 值似乎没有任何效果。始终以 xmin=min(xmin,xmax) 和 xmax=max(xmin,xmax) 显示。

library(ggplot2) ## v0.9.0

## works
qplot(mpg, wt, data = mtcars) +   annotation_raster(rainbow, xmin=15, xmax=20, ymin=3, ymax=4)

## swiching xmin and xmax, doesn't affect plotting
qplot(mpg, wt, data = mtcars) +   annotation_raster(rainbow, xmin=20, xmax=15, ymin=3, ymax=4)

## doesn't work
qplot(mpg, wt, data = mtcars) +   annotation_raster(rainbow, xmin=15, xmax=20, ymin=3, ymax=4) + scale_x_reverse()

我会很感激任何想法。

干杯

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    Kohske 好心地在 ggplot 帮助列表上发布了一个解决方法,它通过对 annotate_raster 使用负坐标解决了这个问题:

    qplot(mpg, wt, data = mtcars) + annotation_raster(rainbow, xmin=-15,
          xmax=-20, ymin=3, ymax=4) + scale_x_reverse() 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多