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.
>Solution :
Consider using group instead of facet_wrap:
ggplot(mutate(mtc, cyl = factor(cyl)), aes(cyl, disp, group = cyl)) +
geom_boxplot()
On using facet_wrap try:
ggplot(mtcars, aes(y=disp))+
geom_boxplot()+
facet_wrap(~factor(cyl))+
scale_x_continuous(breaks = NULL)+
xlab('cyl')

