我想在同一页面上放置多个图。总共有24个地块,其中8个地块的3套有一个共同的图例。另外,所有24个都有一个共同的图例。因此,我想让每个图表都显示3个图例以及所有图例共有的图例。
我尝试单独绘制24个图,然后使用ggarrange(...., nrow = 3,ncol = 8,common.legend = T,图例=“正确”) 有了这个,我只得到一个传说,该传说用于第一个8个地块,然后另一个所有人都通用的传说,但我还需要对另外两个2个八个地块有一个传说。
我想制作出类似于附件中的情节。
#R code used to produce one of the plots for the first set
a = ggbarplot(Arziona, x = "gender", y = "salary", add = c("mean_se"), legend = "bottom", fill = "gender") +
geom_jitter(aes(color = Year), width = 0.2) +
labs(x ="Arizona", y = "Salary (US$)", fill = "Gender") +
theme_classic() + theme(legend.background = element_rect(fill="white",
size=0.5, linetype="solid", colour ="black")) +
theme(axis.text.x = element_text(colour = "black"), axis.text.y = element_text(colour = "black"))+
scale_y_continuous(limits=c(0, 10000), expand = c(0, 0))
a1 = a + theme(plot.title = element_text(hjust = 0.5))
a2 = a1 + geom_text(x = 1, y = 9000, label = "bc") + geom_text(x = 2, y = 9500, label = "a")
a2
a3 = a2 + scale_color_manual(labels = c("2014", "2015", "2016", "2017", "2018"),
values = c("blue", "red", "green", "black", "purple")) + theme(legend.position="right")
a3
a4 = a3
a4
a5 = a4 + theme(axis.text.x = element_blank(),
axis.ticks.x = element_blank()) +
scale_fill_manual(values=c("#FFFFFF", "#CCCCCC"), name = "Gender", labels = c("Male", "Female"))
a5
谢谢您的协助 问候