-
Notifications
You must be signed in to change notification settings - Fork 4
/
theme.Rmd
92 lines (75 loc) · 1.89 KB
/
theme.Rmd
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
# Theme and Title
First, let's try some of the themes from the `ggthemes` package
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_stata()
```
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_economist()
```
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_wsj()
```
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_solarized()
```
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_fivethirtyeight()
```
We can also have complete control over the theme by customizing each element ourselves. Let's start with `theme_minimal()`
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_minimal()
```
Now remove the minor grid lines
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_minimal() +
theme(
panel.grid.minor = element_blank()
)
```
Next, we change the y-axis label
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_minimal() +
theme(
panel.grid.minor = element_blank()
) +
ylab("Home Value (US$)")
```
Then remove the x-axis title since the year is self explanatory
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_minimal() +
theme(
axis.title.x = element_blank(),
panel.grid.minor = element_blank()
) +
ylab("Home Value (US$)")
```
Finally, we can add a title to our plot
```{r}
ggplot(northeast, aes(x = Date, y = Home.Value, color = State)) +
geom_line() +
theme_minimal() +
theme(
axis.title.x = element_blank(),
panel.grid.minor = element_blank()
) +
ylab("Home Value (US$)") +
ggtitle("Housing Market in New York (1975 - 2013)")
```