-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathggtech.Rmd
144 lines (89 loc) · 3.61 KB
/
ggtech.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
title: "ggplot2 extensions: ggtech"
---
### ggtech
<https://github.com/ricardo-bion/ggtech>
ggplot2 tech themes, scales, and geoms.
```{r, message=FALSE,warning=FALSE}
# Example from https://github.com/ricardo-bion/ggtech
library(ggplot2)
library(ggtech)
# Make sure to install the required fonts
# (instructions at the end of this file).
extrafont::font_import(pattern = 'Guardian-EgypTT-Text-Regular.ttf', prompt=FALSE)
d <- qplot(carat, data = diamonds[diamonds$color %in%LETTERS[4:7], ], geom = "histogram", bins=30, fill = color)
```
Tech themes and scales:
```{r}
d + theme_tech(theme="airbnb") + ggtitle("Airbnb ggplot2 theme") + scale_fill_tech(theme="airbnb")
```
```{r}
d + theme_tech(theme="etsy") + ggtitle("Etsy ggplot2 theme") + scale_fill_tech(theme="etsy")
```
```{r}
d + theme_tech(theme="facebook") + ggtitle("Facebook ggplot2 theme") + scale_fill_tech(theme="facebook")
```
```{r}
d + theme_tech(theme="google") + ggtitle("Google ggplot2 theme") + scale_fill_tech(theme="google")
```
```{r}
d + theme_tech(theme="twitter") + ggtitle("Twitter ggplot2 theme") + scale_fill_tech(theme="twitter")
```
Tech geoms, inspired by [emoGG](https://github.com/dill/emoGG).
```{r}
d2 <- data.frame(x = c(1:4, 3:1), y=1:7)
```
```{r}
ggplot(aes(x,y), data=d2) +
geom_tech(size=0.25, theme="airbnb") +
theme_tech("airbnb") +
ggtitle("Airbnb geom")
```
```{r}
ggplot(aes(x,y), data=d2) +
geom_tech(size=0.15, theme="etsy") +
theme_tech("etsy")+
ggtitle("Etsy geom")
```
```{r}
ggplot(aes(x,y), data=d2) +
geom_tech(size=0.15, theme="facebook") +
theme_tech("facebook")+
ggtitle("Facebook geom")
```
```{r}
ggplot(aes(x,y), data=d2) +
geom_tech(size=0.25, theme="google") +
theme_tech("google" ) +
ggtitle("Google geom")
```
```{r}
ggplot(aes(x,y), data=d2) +
geom_tech(size=0.15, theme="twitter") +
theme_tech("twitter") +
ggtitle("Twitter geom")
```
### Install fonts:
You have to install the necessary fonts manually before using `ggtech`. Mofidy the `destfile` if you are using Windows or Unix.
```{r, eval=FALSE}
## Facebook
download.file("http://social-fonts.com/assets/fonts/facebook-letter-faces/facebook-letter-faces.ttf", "/Library/Fonts/facebook-letter-faces.ttf", method="curl")
font_import(pattern = 'facebook-letter-faces.ttf', prompt=FALSE)
font_import(pattern = 'Lucida', prompt=FALSE)
## Google
download.file("http://social-fonts.com/assets/fonts/product-sans/product-sans.ttf", "/Library/Fonts/product-sans.ttf", method="curl")
font_import(pattern = 'product-sans.ttf', prompt=FALSE)
font_import(pattern = 'Roboto', prompt=FALSE)
## Airbnb
download.file("https://dl.dropboxusercontent.com/u/2364714/airbnb_ttf_fonts/Circular%20Air-Medium%203.46.45%20PM.ttf", "/Library/Fonts/Circular Air-Medium 3.46.45 PM.ttf", method="curl")
download.file("https://dl.dropboxusercontent.com/u/2364714/airbnb_ttf_fonts/Circular%20Air-Bold%203.46.45%20PM.ttf", "/Library/Fonts/Circular Air-Bold 3.46.45 PM.ttf", method="curl")
font_import(pattern = 'Circular', prompt=FALSE)
## Etsy
download.file("https://www.etsy.com/assets/type/Guardian-EgypTT-Text-Regular.ttf", "/Library/Fonts/Guardian-EgypTT-Text-Regular.ttf", method="curl")
font_import(pattern = 'Guardian-EgypTT-Text-Regular.ttf', prompt=FALSE)
## Twitter
download.file("http://social-fonts.com/assets/fonts/pico-black/pico-black.ttf", "/Library/Fonts/pico-black.ttf", method="curl")
download.file("http://social-fonts.com/assets/fonts/arista-light/arista-light.ttf", "/Library/Fonts/arista-light.ttf", method="curl")
font_import(pattern = 'pico-black.ttf', prompt=FALSE)
font_import(pattern = 'arista-light.ttf', prompt=FALSE)
```