You can see on one group there is horizontal grey margin, on the other there is none.
How can I make the margin consistent across the facets?
expand.grid(x=1:3, y=1:3)
a<-expand.grid(x=1:3, y=1:3)
a$value=rnorm(9)
a$group=1
b<-expand.grid(x=3, y=1:3)
b$value=rnorm(3)
b$group=2
c<-rbind(a,b)
ggplot(c, aes(x=factor(x), y=factor(y), fill=value)) +
geom_tile() + facet_grid(.~group, scale="free_x", space="free_x")
You should add expand=c(0,0)
inside the scale_x_discrete()
and scale_y_discrete()
to remove grey area.
+scale_x_discrete(expand=c(0,0))+
scale_y_discrete(expand=c(0,0))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With