Annotation_raster not working with scale_x_reverse

I am creating geographic maps with bitmap files as background. For better display, I want to flip some of them to the side (i.e. so that north points to the left and not up). This means that I have to rotate the x-axis (in addition to flipping the x and y) as otherwise the data is not displayed correctly (mirrored).

It works with geom_tile, but of course it is very slow, especially when making faces. So, I want to use annotation_raster. This works great, but only until I format the x axis. Then it is no longer displayed.

Also, I suspect it might be related: swiching the xmin and xmax values ​​have no effect. Always displayed with xmin = min (xmin, xmax) and 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()

      

Any ideas would be appreciated.

Greetings

+3


source to share


1 answer


Kohske kindly posted the desktop in the ggplot reference list, which solved this problem by using negative coordinates for annotate_raster:



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

      

+1


source







All Articles