2
$\begingroup$

I have a series of boxplots that i am generating with ggplot2. I want to control the order in which they are displayed. Is there a way to control this order? I have two genotypes and i want them displayed as WT then KO rather than the reverse (which is what i am getting as a default). My code right now is:

p <- qplot(genotype, activity.ratio, data = df) 
p + geom_boxplot() + geom_jitter()

Also if this is better as a SO question than this forum then please let me know (and if it is the correct forum can someone create a ggplot tag).

$\endgroup$
1
  • $\begingroup$ I don't think a "ggplot" tag will be very useful here (maybe mods would have a different opinion). $\endgroup$
    – chl
    Commented Oct 25, 2010 at 14:16

1 Answer 1

5
$\begingroup$

Would that help?

x <- gl(2, 20, 40, labels=c("KO","WT"))
y <- rnorm(40)
qplot(x,y)
qplot(relevel(x, "WT"),y)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.