Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ggplot: graphic issue with multiple graphs in a column

I want to set a few graphs in one column. The graph output, also the html knit output, does not extend the view frame of all graphs. In this way, the height of each additionally added graph decreases.

Smashed graph view picture

Corresponding code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


p_load(ggplot2)
library(patchwork)
p1 <- ggplot(mpg) + 
  geom_point(aes(x = displ, y = hwy))

p2 <- ggplot(mpg) + 
  geom_bar(aes(x = as.character(year), fill = drv), position = "dodge") + 
  labs(x = "year")

p3 <- ggplot(mpg) + 
  geom_density(aes(x = hwy, fill = drv), colour = NA) + 
  facet_grid(rows = vars(drv))

p4 <- ggplot(mpg) + 
  stat_summary(aes(x = drv, y = hwy, fill = drv), geom = "col", fun.data = mean_se) +
  stat_summary(aes(x = drv, y = hwy), geom = "errorbar", fun.data = mean_se, width = 0.5)

p5 <- ggplot(mpg, aes(x = displ, y = hwy)) + 
  geom_point()

p6 <-ggplot(mpg, aes(displ, hwy, colour = class)) + 
  geom_point()

p1/ p2 / p3 / p4 / p5 / p6


I used Ggplot Arrange Plots Manual

How I can extend the complete view frame height for each added graph?

>Solution :

If you are talking about html knit output from a .Rmd document, the way to increase the display panel for the plot is to edit the parameter of the block of r code. For example:

> ```{r, fig.height=10, fig.width=6}
> p1/ p2 / p3 / p4 / p5 / p6
> ```
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading