Adjusting the relative space of a facet-grid


Usually the relative space of each facet is determined on the basis of equal-size or equal-scale.
In addition, widths and heights arguments in facet_grid can adjust the relative space.


Data and a basic layer:

# data
nr <- 16
fac1 <- gl(2, 1, nr, labels = c("1A", "1B") )
fac2 <- gl(2, 2, nr, labels = c("2C", "2D") )
fac3 <- gl(2, 4, nr, labels = c("3E", "3F") )
fac4 <- gl(2, 8, nr, labels = c("4A", "4B") )
dummy <- data.frame(x = rnorm(nr), y = rnorm(nr), fac1, fac2, fac3, fac4)

# basic layer
p <- ggplot(dummy, aes(x, y)) + geom_point()

 
Equal-size basis:

p + facet_grid(fac1 + fac2 ~ fac3 + fac4)

 
Equal-scale basis:

p + facet_grid(fac1 + fac2 ~ fac3 + fac4, space="free", scale="free")

 
Manual adjustment:

p + facet_grid(fac1 + fac2 ~ fac3 + fac4, widths = 1:4, heights = 4:1)

 
Note that this adjustment enables arbitral mapping from space to value.
Probably, using the manual adjustment without deep consideration would make readers confused.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s