Annotation_raster does not work with scale_x_reverse

29 views
Skip to first unread message

benschee

unread,
Mar 27, 2012, 4:44:41 AM3/27/12
to ggplot2
Hi,

I've already posted this issue on stackoverflow, but I didn't get any
response so far
http://stackoverflow.com/questions/9802936/annotation-raster-does-not-work-with-scale-x-reverse
I suspect it may be a bug, but I'm not sure whether it should better
be reported to the github pages.

I'm creating geographic maps with raster files as background. For
better display I want to flip some of them sidewards (i.e. so that
north points to the left, instead of up). This means that I have to
reverse the x-axis (in addition to flipping x and y), because
otherwise the data are displayed wrongly (mirrored).

It works with geom_tile, but of course this is very slow, especially
when doing facets. So, I want to use annotation_raster. This works
fine as well, but only until I reverse the x-axis. Then it is not
displayed any more.

In addition and I suspect that this may be related: swiching xmin and
xmax values doesn't seem to have any effect. Always displays 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()


Cheers
Benschee

Kohske Takahashi

unread,
Mar 27, 2012, 6:37:10 AM3/27/12
to benschee, ggplot2
Hi

I think this is a bug.

Here is a quick workaround:
qplot(mpg, wt, data = mtcars) + annotation_raster(rainbow, xmin=-15,
xmax=-20, ymin=3, ymax=4) + scale_x_reverse()


2012年3月27日17:44 benschee <b.le...@gmx.de>:

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

--
--
Kohske Takahashi <takahash...@gmail.com>

Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html

benschee

unread,
Mar 27, 2012, 8:03:24 AM3/27/12
to ggplot2
Thank you very much. This solves my problem.

On Mar 27, 12:37 pm, Kohske Takahashi <takahashi.koh...@gmail.com>
wrote:
> Hi
>
> I think this is a bug.
>
> Here is a quick workaround:
> qplot(mpg, wt, data = mtcars) +   annotation_raster(rainbow, xmin=-15,
> xmax=-20, ymin=3, ymax=4) + scale_x_reverse()
>
> 2012年3月27日17:44 benschee <b.leut...@gmx.de>:
>
>
>
>
>
>
>
>
>
> > Hi,
>
> > I've already posted this issue on stackoverflow, but I didn't get any
> > response so far
> >http://stackoverflow.com/questions/9802936/annotation-raster-does-not...
> Kohske Takahashi <takahashi.koh...@gmail.com>

Hadley Wickham

unread,
Apr 11, 2012, 3:55:27 PM4/11/12
to benschee, ggplot2
Could you please file a bug?
Thanks!
Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Kohske Takahashi

unread,
Apr 15, 2012, 10:46:22 PM4/15/12
to Hadley Wickham, benschee, ggplot2
Did anyone file this bug?

2012年4月12日4:55 Hadley Wickham <had...@rice.edu>:

--
--
Kohske Takahashi <takahash...@gmail.com>

benschee

unread,
Apr 16, 2012, 10:19:23 PM4/16/12
to ggplot2
yes, now I did
https://github.com/hadley/ggplot2/issues/500

On Apr 16, 4:46 am, Kohske Takahashi <takahashi.koh...@gmail.com>
wrote:
> Did anyone file this bug?
>
> 2012年4月12日4:55 Hadley Wickham <had...@rice.edu>:
>
>
>
>
>
>
>
>
>
> > Could you please file a bug?
> > Thanks!
> > Hadley
>
> > On Tue, Mar 27, 2012 at 3:44 AM, benschee <b.leut...@gmx.de> wrote:
> >> Hi,
>
> >> I've already posted this issue on stackoverflow, but I didn't get any
> >> response so far
> >>http://stackoverflow.com/questions/9802936/annotation-raster-does-not...
> Kohske Takahashi <takahashi.koh...@gmail.com>

Kohske Takahashi

unread,
Apr 16, 2012, 10:24:44 PM4/16/12
to benschee, ggplot2
thanks.


2012年4月17日11:19 benschee <b.le...@gmx.de>:

> Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

--
--
Kohske Takahashi <takahash...@gmail.com>

Reply all
Reply to author
Forward
0 new messages