Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I get rid of the numbers at the bottom of the boxplots?

enter image description here

ggplot(mtc, aes(cyl, disp))+
  geom_boxplot()+
  facet_wrap(~cyl)

Above is a image of boxplots using the data from mtcars in R, and my original code. How do I get rid of the numbers at the bottom of the graph, as I already have the cylinder numbers at the top?

Changing the axis.text and axis.title using theme() didn’t help. It just stretched/shrunk the plot by a tiny amount.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Consider using group instead of facet_wrap:

ggplot(mutate(mtc, cyl = factor(cyl)), aes(cyl, disp, group = cyl)) +
   geom_boxplot()

enter image description here


On using facet_wrap try:

ggplot(mtcars, aes(y=disp))+
  geom_boxplot()+
  facet_wrap(~factor(cyl))+
  scale_x_continuous(breaks = NULL)+
  xlab('cyl')

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading