簡體   English   中英

ggplot:一列中有多個圖形的圖形問題

[英]ggplot: graphic issue with multiple graphs in a column

我想在一欄中設置幾個圖表。 圖output,也是html knit output,不擴展所有圖的視圖框架。 這樣,每增加一個圖形的高度就會降低。

碎圖查看圖片

對應代碼:


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


我使用了 Ggplot Arrange Plots Manual

如何為每個添加的圖形擴展完整的視圖框架高度?

如果你說的是html knit output from a.rmd文件,增加plot顯示面板的方法是編輯r代碼塊的參數。 例如:

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