In a ggplot histogram, I want to know how to have the x-axis in each facet but have the strip labels unstacked

268 Views Asked by At

I'll start with a simple faceted histogram using mtcars, faceting on the variables vs and am.

library(ggplot2)
data(mtcars)
ggplot(mtcars, aes(wt)) + 
    geom_histogram() + 
    facet_grid(vs ~ am)

I want to have the x-axis label underneath each facet so switch to facet_wrap.

ggplot(mtcars, aes(wt)) + 
    geom_histogram() + 
    facet_wrap(vs ~ am, nrow = 2, scales = "free")

Now the strips for vs and am are stacked. How can I make the strips for am go across the top and the strips for vs appear on the right side as is the case in the first histogram using facet_grid?

0

There are 0 best solutions below