How to have x axis labels in multi-column ggplot with facet_wrap?

When trying to build something like this:

library(ggplot2) d <- ggplot(diamonds, aes(carat, price)) + xlim(0, 2) + geom_point() d + facet_wrap(~ color) 

You will notice that labels along the x axis are displayed only for the first column. I would like them to repeat the second and third columns. Is it possible?

If on facet_wrap I use the parameter scale = "free",

 d + facet_wrap(~ color, scales="free") 

then I get the x-axis labels on all graphs, which I don’t want either. I want only the labels in the bottom row to be repeated in columns

If the number of panels to be displayed is such that all columns have the same number of graphs, the axis repeats the way I want. But I do not always have the right amount of panels for this.

+6
source share
1 answer
+1
source

Source: https://habr.com/ru/post/944952/


All Articles