ggplot2:组合绘图时固定轴高度/宽度 库(ggplot2) 图书馆(gridExtra) df1

ggplot2:组合绘图时固定轴高度/宽度 库(ggplot2) 图书馆(gridExtra) df1,r,ggplot2,R,Ggplot2,您可以将ggarrangefrom与参数align=“v” 您可以将ggarrangefrom与参数align=“v” 这里有两个选项:egg::ggarrange(p1,p2)或cowplot::plot\u grid(p1,p2,align=“v”,ncol=1)。此小插曲中的一些讨论:这里有两个选项:egg::ggarrange(p1,p2)或cowplot::plot\u grid(p1,p2,align=“v”,ncol=1)。此小插曲中的一些讨论: library(ggplot2)

您可以将
ggarrange
from与参数
align=“v”


您可以将
ggarrange
from与参数
align=“v”


这里有两个选项:
egg::ggarrange(p1,p2)
cowplot::plot\u grid(p1,p2,align=“v”,ncol=1)
。此小插曲中的一些讨论:这里有两个选项:
egg::ggarrange(p1,p2)
cowplot::plot\u grid(p1,p2,align=“v”,ncol=1)
。此小插曲中的一些讨论:
library(ggplot2)
library(gridExtra)

df1 <- data.frame(x=c("A1","A2","A3","A4"),something=c(10,18,24,32))
df2 <- data.frame(x=c("C1","C2","C3","C4"),somethingelse=c(10543,182334,242334,32255))


p1 <- ggplot(df1,aes(x,something))+
  geom_bar(stat="identity")
p2 <- ggplot(df2,aes(x,somethingelse))+
  geom_bar(stat="identity")


png("test.png",height=8,width=6,res=120,units="cm")
gridExtra::grid.arrange(p1,p2,heights=grid::unit(c(4,4),"cm"))
dev.off()
# Plotting figures provided by OP
ggpubr::ggarrange(p1, p2, heights = c(4, 4), nrow = 2, align = "v")