This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
font and theme.R
44 lines (41 loc) · 1.71 KB
/
font and 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
library(showtext)
font_add("SourceHanSerif",regular = "/Library/Fonts/SourceHanSerif-Regular.ttc",
bold="SourceHanSerif-Bold.ttc")
par(family = "SourceHanSerif")
showtext_auto()
#==========
# set my theme
#==========
theme_ou <- function(){
font <- "SourceHanSerif" #assign font family up front
theme_minimal() %+replace% #replace elements we want to change
theme(
panel.grid.major = element_blank(), #strip major gridlines
panel.grid.minor = element_blank(), #strip minor gridlines
axis.ticks = element_blank(), #strip axis ticks
plot.title = element_text( #title
family = font, #set font family
size = 20, #set font size
face = 'bold', #bold typeface
hjust = 0, #left align
vjust = 0), #raise slightly
plot.subtitle = element_text( #subtitle
family = font, #font family
size = 14), #font size
plot.caption = element_text( #caption
family = font, #font family
size = 9, #font size
hjust = 1), #right align
axis.title = element_text( #axis titles
family = font, #font family
size = 15,
face='bold'), #font size
axis.text = element_text( #axis text
family = font, #axis famuly
size = 15), #font size
axis.text.x = element_text( #margin for axis text
margin=margin(5, b = 10)),
legend.text = element_text(size=10,
family = font)
)
}