I am a relatively new user (and am so far very impressed!) so
please forgive me if this is a quite basic question. I am trying to
make plots in which the x axis is reversed (numbers go from large to
small as you go left to right). Until a few days ago I was able
accomplish this simply by the ordering of xlim the
scale_x_continuous(). Recently however, this seems to have stopped
working (due to some sort of change in the package?). Now it does not
matter whether I use scale_x_continuous(0,10) or
scale_x_continuous(10,0) -the axis always goes from small to large
numbers.
I've tried using scale_x_reverse as a fix, and this works by itself
except that I am also trying to add lines to the plot using
geom_vline(), and when I do this, instead of plotting the vline at
xintercept = X, ggplot2 plots it at -X:
X <-rnorm(100,5,2)
Y <-rnorm(100,5,2)
p <- qplot(X,Y)
p + scale_x_reverse() + geom_vline(xintercept = 6)
If I change xintercept to -X, it plots the vline at X but still
extends the x axis out to -X even though there is nothing plotted
there. Can anybody either (A) explain to me why the ordering of xlims
no longer controls axis direction or (B) tell me if there is a way
around the problems I'm having with scale_x_reverse?
cheers,
Seth
Mapping xintercept as an aesthetic solves the problem. Nevertheless I think
the behavior is strange (should just produce an error?)
Hope this helps,
fernando
library(ggplot2)
X <-rnorm(100,5,2)
Y <-rnorm(100,5,2)
p <- qplot(X,Y)
p + scale_x_reverse() + geom_vline(aes(xintercept = 6))
-----Mensaje original-----
De: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com] En nombre de
Seth Finnegan
Enviado el: jueves, 10 de junio de 2010 21:02
Para: ggp...@googlegroups.com
Asunto: adding geom_vline() to reversed x-axis
Hello-
cheers,
Seth
--
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/