简体   繁体   English

ggplot:一列中有多个图形的图形问题

[英]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.图output,也是html knit output,不扩展所有图的视图框架。 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我使用了 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.如果你说的是html knit output from a.rmd文件,增加plot显示面板的方法是编辑r代码块的参数。 For example:例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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