样本数据
df<-data.frame(id=1:10,pop=(1:10)^2,gr=c(“a”,rep(“b”,8),“a”))
df饼<-df%>%
分组依据(gr)%>%
总结(年=n(),
pop_years=总和(pop)
A<-ggplot(df,aes(x=id,col=gr,fill=gr))。+
土工格栅()。+
主题(legend.position=“none”)
b<-ggplot(df_pie,aes(x=因子(1),y=年,fill=gr))。+
土工格栅(宽度=1,stat=“Identity”)。+
坐标极坐标(“Y”,开始=0)+
主题(legend.position=“none”)
C<-ggplot(df,aes(x=id,y=pop,col=gr,fill=gr))。+
几何条形图(stat=“identity”)。+
主题(legend.position=“bottom”)
D<-ggplot(df_pie,aes(x=因子(1),y=pop_years,fill=gr))。+
土工格栅(宽度=1,stat=“Identity”)。+
坐标极坐标(“Y”,开始=0)+
主题(legend.position=“none”)
编辑
多亏了@hpesoj626,我知道如何制作所有东西,但条件3仍然适用-通用背景色

编辑2
我已经创建了以下图表
but the space between plots and titles are hurge
通用背景色
不同地块大小
底部有一个传说
它看起来应该是这样的:

我找到了一些零碎的照片,但我不知道怎么穿。
添加我使用的主标题Place title of multiplot panel with ggplot2
layout <- matrix(c(1, 1, 2, 3, 3, 4), nrow = 2, byrow = TRUE)
grid.arrange(A, B, C, D, top = "Title",
layout_matrix = layout)

我找到了函数multiplot(http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2)/)它允许绘制不同尺寸的图表,但其他要求不满足。
plot_list <- list(A, B, C, D)
layout <- matrix(c(1, 1, 2, 3, 3, 4), nrow = 2, byrow = TRUE)
multiplot(plotlist = plot_list, layout = layout)

我还发现了如何创建通用图例,但图表大小相同(Add a common Legend for combined ggplots)
grid_arrange_shared_legend <- function(...) {
plots <- list(...)
g <- ggplotGrob(plots[[1]] + theme(legend.position="bottom"))$grobs
legend <- g[[which(sapply(g, function(x) x$name) == "guide-box")]]
lheight <- sum(legend$height)
grid.arrange(
do.call(arrangeGrob, lapply(plots, function(x)
x + theme(legend.position="none"))),
legend,
ncol = 1,
heights = unit.c(unit(1, "npc") - lheight, lheight))
}
grid_arrange_shared_legend(A, B, C, D)

样本数据
DF <- data.frame(ID = 1:10, Pop = (1:10)^2, gr = c("A", rep("B", 8), "A"))
DF_Pie <- DF %>%
group_by(gr) %>%
summarise(Years = n(),
Pop_Years = sum(Pop))
A <- ggplot(DF, aes(x = ID, col = gr, fill = gr)) +
geom_bar()+
theme(legend.position="none")
B <- ggplot(DF_Pie, aes(x = factor(1), y = Years, fill = gr))+
geom_bar(width = 1, stat = "identity") +
coord_polar("y", start=0)+
theme(legend.position="none")
C <- ggplot(DF, aes(x = ID, y = Pop, col = gr, fill = gr)) +
geom_bar(stat="identity") +
theme(legend.position="bottom")
D <- ggplot(DF_Pie, aes(x = factor(1), y = Pop_Years, fill = gr))+
geom_bar(width = 1, stat = "identity") +
coord_polar("y", start=0) +
theme(legend.position="none")
编辑
多亏了@hpesoj626,我知道如何制作所有东西,但条件3仍然适用-通用背景色

编辑2
我创建了以下图表
但是情节和标题之间的空间是巨大的