Increase the size of plot


I have an R script which works well if the facet_wrap's n_row is small. However if I increase n_row to a large number the plot area of each chart is reduced to a very small plot. Here is the script:

group_by(Session,Site,Risk) %>%
    summarise(n=n()) %>% top_n(10)
  plot1 <- ggplot(DF, aes(x = Session, y = n, color = Risk)) +
    theme(axis.text.x = element_text(angle = 45), legend.position="bottom",
          legend.text = element_text(size=7))  + geom_point() +
    geom_line(aes(group = Risk), lty = 3) + guides(colour = guide_legend(nrow = 3)) +
    facet_wrap(~ Site, nrow = 4)
  ggplotly(plot1) %>% layout(legend = list(orientation = "h", x = 0.4, y = -0.2))

so for nrow=4, the charts look acceptable:

However if I increase nrow to 32 in order to see only one chart per line, it becomes like this:

So I was thinking to increase the the vertical size of the overall plot if that is the best approach.

How do I do it? Or is there a better way?

Hi @zorro,

As you didn't mention where the plot needs to be displayed I can point you to these resources:

See chapter Figure sizing of the R4DS book

See chapter Output for Presentation of the Graphics Cookbook

If it concerns an R Markdown document, then section Options can be insightful:

If, however, you want to change the size in the Plots plane of your RStudio, then you can select Export > Copy to Clipboard.. where yo have the ability to resize your plot. You may find the checkbox Maintain aspect ratio useful.

Hope this provides you some help in the right direction.

Thanks Lars, I am actually expecting to see it on the viewer itself however your suggestion solves my problem.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.