-1

here is my code:

> hdata$Mono<- factor(hdata$Mon)

> ggplot(hdata, aes(y= Test1, x= Mono))+ geom_boxplot()

And this is what it is giving:

enter image description here

I want to format the x axis in a way so that it will start from 12 and go like this 12, 1, 2, 3, 4, 5, 6 ,7, 8

Mac
  • 111
  • 1
  • 2
  • 10
  • look at the answer here just change the variable and sign in reorder:http://stackoverflow.com/questions/42184869/sorting-dataframe-for-ggplot-barplot/42186399#42186399 – Biranjan Feb 16 '17 at 20:02

1 Answers1

3

Just do

hdata$Mono<- factor(hdata$Mon, levels = c(12, 1:8))

factor by default orders the levels in ascending order. You can order them yourself by using the levels argument.

Rentrop
  • 20,979
  • 10
  • 72
  • 100