[R] Order labels in qplot() - ggplot2 {help}
baptiste auguie
bapt4510 at googlemail.com
Thu Jun 10 20:50:13 CEST 2010
Hi,
You could reorder the factor levels before plotting,
x$n = factor(x$n, levels=c("va","vp", letters[1:3]))
last_plot() %+% x
or you could avoid using factors in the first place,
x <- data.frame(cbind(n,p,pm,pn), stringsAsFactors=FALSE)
last_plot() %+% x
HTH,
baptiste
On Thu, Jun 10, 2010 at 8:42 PM, Kim Jung Hwa <kimhwamaillist at gmail.com> wrote:
> Hello,
>
> I want to arrage the label according to my preference eg.. (va, vp, a, b,
> c) but don't know how to supress default ordering. Any
> suggestions?
>
> Please try the code below:
>
> n <- c("va", "vp", "a", "b", "c")
> p <- c(2, 2,1, 3,5)
> pm<- c(3,4,2,5,4)
> pn <- c(1,1,1,2,3)
> x<-data.frame(cbind(n,p,pm,pn))
> library(ggplot2)
> qplot(x=n, y=p, data=x, ymin=pn, ymax=pm,
> xlab='', ylab='', main='Order Label as: va vp a b c') +
> geom_hline(yintercept = 2) +
> geom_linerange() +
> coord_flip()
>
> Thanks!
>
> --
> 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 ggplot2 at googlegroups.com
> To unsubscribe: email ggplot2+unsubscribe at googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
More information about the R-help
mailing list