Add x and y axis to all facet_wrap

Solution 1:

This should simplify things considerably:

library('ggthemes')
ggplot(mtcars, aes(mpg, hp)) + geom_point() + facet_wrap(~carb, scales='free') + 
    theme_tufte() + theme(axis.line=element_line()) + 
    scale_x_continuous(limits=c(10,35)) + scale_y_continuous(limits=c(0,400))

enter image description here

Solution 2:

easiest way would be to add segments in each plot panel,

ggplot(mtcars, aes(mpg, hp)) + 
  geom_point() + 
  facet_wrap(~carb) +
  theme_minimal() +
  annotate("segment", x=-Inf, xend=Inf, y=-Inf, yend=-Inf)+
  annotate("segment", x=-Inf, xend=-Inf, y=-Inf, yend=Inf)

example

Solution 3:

Following Thomas answer from above -

You just need to set scales='free' in facet_wrap and make sure to set the limits in scale_x_continuous and scale_y_continuous

ggplot(mtcars, aes(mpg, hp)) + geom_point() + facet_wrap(~carb, scales='free') + 
    scale_x_continuous(limits=c(10,35)) + scale_y_continuous(limits=c(0,400))