-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_step.R
109 lines (85 loc) · 3.67 KB
/
plot_step.R
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
library(tidyverse)
library(patchwork)
df1 <- readxl::read_excel("simulation_data.xlsx",sheet = "plot-iid")
df2 <- readxl::read_excel("simulation_data.xlsx",sheet = "plot-hete")
df3 <- readxl::read_excel("simulation_data.xlsx",sheet = "plot-wang")
df4 <- readxl::read_excel("simulation_data.xlsx",sheet = "plot-diverge")
# Reshape the data into a long format
data_long1 <- df1 %>%
pivot_longer(cols = SC:FDR, names_to = "Metric", values_to = "Value") %>%
mutate( Metric = factor(Metric, levels = c("SC", "CF", "PSR", "FDR")), m=factor(m, levels = c("m=5", "m=10", "m=20") ), methods = factor(methods, levels = c("Pearson", "Kendall", "SIRS", "DC", "DSQR (0.75)", "DFS-QR (0.25)", "DFS-QR (0.50)", "DFS-QR (0.75)")) )
p1 <- ggplot( data_long1, aes(x = Metric, y = Value, group = methods, colour = methods) ) +
geom_line( ) +
geom_point( ) +
facet_grid(m ~ setting) +
# theme_minimal() + # Use a minimal theme
labs(
title = "Performance of indicators for example 1",
x = "Metric",
y = "Value",
color = "Methods"
) +
theme(
plot.title = element_text(size = 10)
)
data_long2 <- df2 %>%
pivot_longer(cols = SC:FDR, names_to = "Metric", values_to = "Value") %>%
mutate( Metric = factor(Metric, levels = c("SC", "CF", "PSR", "FDR")), m=factor(m, levels = c("m=5", "m=10", "m=20") ), methods = factor(methods, levels = c("Pearson", "Kendall", "SIRS", "DC", "DSQR (0.75)", "DFS-QR (0.25)", "DFS-QR (0.50)", "DFS-QR (0.75)")) )
p2 <- ggplot( data_long2, aes(x = Metric, y = Value, group = methods, colour = methods) ) +
geom_line( ) +
geom_point( ) +
facet_grid(m ~ setting) +
# theme_minimal() + # Use a minimal theme
labs(
title = "Performance of indicators for example 2",
x = "Metric",
y = "Value",
color = "Methods"
) +
theme(
plot.title = element_text(size = 10)
)
data_long3 <- df3 %>%
pivot_longer(cols = SC:FDR, names_to = "Metric", values_to = "Value") %>%
mutate( Metric = factor(Metric, levels = c("SC", "CF", "PSR", "FDR")), m=factor(m, levels = c("m=5", "m=10", "m=20") ), methods = factor(methods, levels = c("Pearson", "Kendall", "SIRS", "DC", "DSQR (0.75)", "DFS-QR (0.25)", "DFS-QR (0.50)", "DFS-QR (0.75)")) )
p3 <- ggplot( data_long3, aes(x = Metric, y = Value, group = methods, colour = methods) ) +
geom_line( ) +
geom_point( ) +
facet_grid(m ~ setting) +
# theme_minimal() + # Use a minimal theme
labs(
title = "Performance of indicators for example 3",
x = "Metric",
y = "Value",
color = "Methods"
) +
theme(
plot.title = element_text(size = 10)
)
data_long4 <- df4 %>%
pivot_longer(cols = SC:FDR, names_to = "Metric", values_to = "Value") %>%
mutate( Metric = factor(Metric, levels = c("SC", "CF", "PSR", "FDR")), m=factor(m, levels = c("m=5", "m=10", "m=20") ), methods = factor(methods, levels = c("Pearson", "Kendall", "SIRS", "DC", "DSQR (0.75)", "DFS-QR (0.25)", "DFS-QR (0.50)", "DFS-QR (0.75)")) )
p4 <- ggplot( data_long4, aes(x = Metric, y = Value, group = methods, colour = methods) ) +
geom_line( ) +
geom_point( ) +
facet_grid(m ~ setting) +
# theme_minimal() + # Use a minimal theme
labs(
title = "Performance of indicators for example 4",
x = "Metric",
y = "Value",
color = "Methods"
) +
theme(
plot.title = element_text(size = 10)
)
p <- p1 + p2 + plot_layout(guides = "collect")
q <- p3 + p4 + plot_layout(guides = "collect")
ggsave(
plot = q,
filename = "example-3-4.png",
path = "picture",
width = 8,
height = 5,
dpi = 1000
)