0

I have a question regarding the distribution of the data along the x-axis in my plot area.

Currently the data in my example is displayed in this order: Fair - Good - Very Good - Premium - Ideal

I want to change this distribution to Ideal - Premium - Very Good - Good - Fair

Basically what I want to do is to mirror the distribution of the data on the x-axis. Can you please tell me if there is a possibility to do so and if there is one, how can i do it?

Please let me know, if you need any further information.

Roland

rdw
  • 3
  • 2
  • Check [here](http://www.stackoverflow.com/questions/12774210/how-do-you-specifically-order-ggplot2-x-axis-instead-of-alphabetical-order). – jlhoward Dec 24 '13 at 21:10

1 Answers1

1

Sounds like you're using the diamonds dataset.

gg <- diamonds
ggplot(gg) + geom_bar(aes(x=cut))

gg$cut <- factor(gg$cut,
                 levels=c("Ideal","Premium","Very Good","Good","Fair"), 
                 ordered=TRUE)
ggplot(gg) + geom_bar(aes(x=cut))

jlhoward
  • 58,004
  • 7
  • 97
  • 140