简体   繁体   中英

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.

碎图查看图片

Corresponding code:


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?

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
> ```

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM