-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path16 Combine graphs same plot GGPLUBR.R
More file actions
47 lines (40 loc) · 1.56 KB
/
Copy path16 Combine graphs same plot GGPLUBR.R
File metadata and controls
47 lines (40 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 16 Multiple graphs on same plot
# ggpubr: Publication Ready Plots / Mix Multiple Graphs on The Same Page
# Combine three plots into a single output image
# We use ggpubr to combine three plots together
library(ggpubr)
# Plot 01
PLOT_mtype1 <- Indic_type_FLAG %>%
select(Indic_type) %>%
ggplot(aes(Indic_type)) +
geom_bar(fill = "darkorchid") +
geom_text(stat='count',aes(label =..count..),vjust = -0.5) +
labs(title = "Metric by measure type on dataset",
subtitle = "Time period: 2020/21 FY")
PLOT_mtype1
# Plot 02
PLOT_mtype2 <- Indic_type_FLAG %>%
select(Indic_type) %>%
ggplot(aes(Indic_type)) +
geom_bar(fill = "royalblue1") +
geom_text(stat='count',aes(label =..count..),vjust = -0.5) +
labs(title = "Metric by measure type on dataset",
subtitle = "Time period: 2020/21 FY")
PLOT_mtype2
# Plot 03
PLOT_mtype3 <- Indic_type_FLAG %>%
select(Indic_type) %>%
ggplot(aes(Indic_type)) +
geom_bar(fill = "slategray3") +
geom_text(stat='count',aes(label =..count..),vjust = -0.5) +
labs(title = "Metric by measure type on dataset",
subtitle = "Time period: 2020/21 FY")
PLOT_mtype3
# THEN we combine these three plots using library(ggpubr)
# ggarrange to combine three ggplots in one image
# ARRANGE PLOT IN A 3 COLS BY 1 ROW MATRIX
ggarrange(PLOT_mtype1, PLOT_mtype2, PLOT_mtype3 + rremove("x.text"),
labels = c("A", "B", "C"),
ncol = 3, nrow = 1)
ggsave(paste0("Combined plot",".jpeg"),
width = 30, height = 20, dpi = 150, units = "cm")