Naumz
Naumz

Reputation: 481

Using facet_wrap and ggsave in a figure with many panels

I'm trying to generate scatter plots of two variables for several values of a third categorical variable (around 350). Here's my current code:

my.plot <- ggplot(aes(x=first_variable, y=second_variable, color=fourth_variable), data=my.data) + 
           geom_point() +
           facet_wrap(~ third_variable, scales = 'free')
ggsave(filename='test_plot.jpg', plot=my.plot, width=20, height=20, units='in', limitsize=FALSE)

However, the saved figure has font that is too big in relation to a plot area that is skewed and compressed. Is there a way I can shrink each panel's entire contents, font and all, to avoid overlapping and get good plots in the saved file?

These are two samples of the figure.

enter image description here enter image description here

Upvotes: 0

Views: 1022

Answers (1)

edavidaja
edavidaja

Reputation: 728

You can try reducing the size of all of the text with something like + theme(text = element_text(size = 10)), or look through the elements of theme to set text sizes for more specific elements.

Upvotes: 1

Related Questions