I'm using facet_wrap with ggplot to create a plot of facets. My problem is that my facets always come out looking like very short, very wide rectangles, but I want them to be square so they are easier to understand. Ideally, I would like to specify the number of columns I desire, and have ggplot figure out what the height of the plot should be so that all the facets are square. Is this possible?
Maybe aspect.ratio
helps:
df <- data.frame(x = runif(100, 0,10), y = runif(100, 0, 50), z=gl(4,25))
ggplot(df, aes(x, y)) +
geom_point() +
facet_wrap(~ z, ncol = 4) +
theme(aspect.ratio = 1) # try with and without
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