Facet_Wrap is congested for More levels of factor in my dataset

I have a dataset df where i Need to find the correlation between x and y variable and also I need to see with different locations. The issues the locations are more (Say 95) and when I plot the code with ggplot, the output is congested and not very clear. Is it possible to increase the layout of ggplot so that I can scroll down to see the plots. I cannot share the sample here since it is huge. I this is how I tried

df
    X     Y     Location
    4     6       L1
    5     10      L2
    7     45      L1
    -     -       - 
    -     -       - 
    3      6      L95  
 ggplot(df,aes(x=X,y=Y,fill=Location))+geom_point()+facet_wrap("Location",scales = "free_y")+theme(legend.position = "none")

But the result is very congested and it is fitting all 95 locations one screen only.

:scream: 95 five is a lot of facets, so I'm not surprised that things are getting scrunched up! ggplot2 is built on top of the very powerful grid graphics system, which automatically resizes to fit the viewer window (which is what I'm guessing you're looking at in RStudio). See, for example, in the tweet from Thomas (one of the maintainers of ggplot2), below:

You can change the height, width, and aspect ratio of a plot in order to save it using ggsave() (see thread below), or in an R Markdown document by setting the fig.* options for a specific code chunk (or the whole document, if you so choose — see the knitr code chunk options at this link).

If you're printing something, the ggforce package has new functions that allow you to paginate faceted plots:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.