-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBoxPlotR_functions.R
More file actions
60 lines (60 loc) · 1.55 KB
/
Copy pathBoxPlotR_functions.R
File metadata and controls
60 lines (60 loc) · 1.55 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
48
49
50
51
52
53
54
55
56
57
58
59
60
# Specifies the arrangement of data points (normal or jittered).
# point_type: 0 = normal, 2 = jittered
jittered_points <- function(data_matrix, my_horizontal = FALSE, point_type,
point_colors, point_transparency, point_size) {
# normal boxplots
if (my_horizontal) {
for (i in seq_len(ncol(data_matrix))) {
alpha_val <- 255 * (point_transparency / 100)
col_rgb <- rgb(
t(col2rgb(point_colors[i])),
maxColorValue = 255,
alpha = alpha_val
)
if (point_type == 0) {
points(
data_matrix[, i],
rep(i, nrow(data_matrix)),
col = col_rgb,
pch = 16,
cex = point_size
)
} else {
points(
data_matrix[, i],
jitter(rep(i, nrow(data_matrix)), amount = 0.25),
col = col_rgb,
pch = 16,
cex = point_size
)
}
}
} else {
# horizontal boxplots
for (i in seq_len(ncol(data_matrix))) {
alpha_val <- 255 * (point_transparency / 100)
col_rgb <- rgb(
t(col2rgb(point_colors[i])),
maxColorValue = 255,
alpha = alpha_val
)
if (point_type == 0) {
points(
rep(i, nrow(data_matrix)),
data_matrix[, i],
col = col_rgb,
pch = 16,
cex = point_size
)
} else {
points(
jitter(rep(i, nrow(data_matrix)), amount = 0.25),
data_matrix[, i],
col = col_rgb,
pch = 16,
cex = point_size
)
}
}
}
}