How to plot boxplots at once when your x variable has more than 10 values

Viewed 32

I used the following code for plotting the variable TYPE (which has around 100 factors) vs the variable MEASURE. I don't mind having separate boxplots, but I will like to know if there is a way to plot or code all factors at once instead of one by one.

figa <- ggplot(dftest, aes(x = TYPE, y =  MEASURE))+
  geom_boxplot()
figa

enter image description here

1 Answers

It seems you are plotting all the TYPE factors, and they are not readable.

I add +coord_flip() to boxplots to make the result more readable:

library(tidyverse)
g<-ggplot(iris, aes(x = Species, y =  Sepal.Length))+
  geom_boxplot()+
  coord_flip()
ggsave("test.png", g, height = 15 , width = 7) # tall 15x7 for example

enter image description here

Related