-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.R
62 lines (54 loc) · 2.72 KB
/
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
theme_brew <-
function(base_size = 8){#, base_family = "Arial") {
require(RColorBrewer)
# Generate the colors for the chart procedurally with RColorBrewer
# palette <- brewer.pal("Greys", n=9)
palette <- colorRampPalette(c('white', 'white', 'black'))(9)
color_background = palette[2]
color_grid_major = palette[6]
color_axis_text = palette[8]
color_axis_title = palette[8]
color = palette[8]
color_title = palette[9]
# Begin construction of chart
theme_bw(base_size=base_size) +
# Set the entire chart region to seasheel
theme(panel.background=element_rect(fill=color_background,
color=color_background)) +
theme(plot.background=element_rect(fill=color_background,
color=color_background)) +
theme(panel.border=element_rect(color=color_background)) +
# Format the grid
theme(panel.grid.major=element_line(color=color_grid_major,
size=.25)) +
theme(panel.grid.minor=element_blank()) +
theme(axis.ticks=element_blank()) +
# Format the legend, but hide by default
# theme(legend.position="none") +
theme(legend.background = element_rect(fill=color_background)) +
theme(legend.text = element_text(#family = base_family,
size=base_size * 0.7,
color=color_axis_title)) +
# Set title and axis labels, and format these and tick marks
theme(plot.title=element_text(#family = base_family,
color=color_title,
size=base_size*1.2,
vjust=1.25)) +
theme(axis.text.x=element_text(#family = base_family,
size=base_size * 0.8,
color=color_axis_text)) +
theme(axis.text.y=element_text(#family = base_family,
size=base_size * 0.8,
color=color_axis_text)) +
theme(axis.title.x=element_text(#family = base_family,
size=base_size * 0.8,
color=color_axis_title,
vjust=0)) +
theme(axis.title.y=element_text(#family = base_family,
size=base_size * 0.8,
color=color_axis_title,
vjust=1.25)) +
# Plot margins
theme(plot.margin = unit(c(0.35, 0.2, 0.3, 0.35), "cm")) +
theme(complete = TRUE)
}