-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathggplot_custom_theme.R
66 lines (62 loc) · 1.76 KB
/
ggplot_custom_theme.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
# creating dummy data
# data("iris")
# library(tidyverse)
#
# iris %>%
# rename_all(tolower) ->iris
# iris %>%
# ggplot(aes(species,sepal.length,
# col=species)) +
# geom_point() -> dummy;dummy
# Setting a custom ggplot2 function
theme_jpb <- function() {
theme_bw() +
theme(
axis.text.x = element_text(size = 12,
vjust = 1),
axis.text.y = element_text(size = 12),
axis.title.x = element_text(size = 14, face = "plain"),
axis.title.y = element_text(size = 14, face = "plain"),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "cm"),
plot.title = element_text(
size = 20,
vjust = 1,
hjust = 0.5
),
legend.text = element_text(size = 12, face = "italic"),
legend.title = element_blank()
)
}
theme_custom <- function() {
theme_bw() +
theme(
axis.text.x = element_text(
size = 12,
angle = 45,
vjust = 1,
hjust = 1
),
axis.text.y = element_text(size = 12),
axis.title.x = element_text(size = 14, face = "plain"),
axis.title.y = element_text(size = 14, face = "plain"),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.major.y = element_blank(),
plot.margin = unit(c(0.5, 0.5, 0.5, 0.5), "cm"),
plot.title = element_text(
size = 20,
vjust = 1,
hjust = 0.5
),
legend.text = element_text(size = 12, face = "italic"),
legend.title = element_blank(),
legend.position = c(0.9, 0.9)
)
}
# applying custom theme
# dummy +
# theme_custom() +
# theme(legend.position = c(.1,.9)) +
# labs(x="Species",
# y="Sepal length (units)")