forked from jrnold/ggthemes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
199 lines (145 loc) · 5.54 KB
/
README.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
```{r header,echo=FALSE,results='hide'}
opts_knit$set(upload.fun = imgur_upload)
opts_chunk$set(fig.width = 5.25, fig.height = 3.75, cache=FALSE)
```
# ggthemes
Some extra geoms, scales, and themes for
[ggplot](http://had.co.nz/ggplot2/), including
## Geoms
- ``geom_rangeframe`` : Tufte's range frame
- ``geom_tufteboxplot``: Tufte's box plot
## Themes
- ``theme_tufte``: a minimal ink based on Tufte's *The Visual Display of
Quantitative Information*.
- ``theme_solarized``: a theme using the [solarized](http://ethanschoonover.com/solarized) color palette.
- ``theme_stata``: themes based on [Stata](http://stata.com/) graph schemes.
- ``theme_economist``: a theme based on the plots in the [The Economist](http://www.economist.com/) magazine.
- ``theme_excel``: a theme replicating the classic ugly gray charts in Excel
- ``theme_wsj``: a theme based on the plots in the [The Economist](http://www.economist.com/) magazine.
- ``theme_few``: theme from Stephen Few's ["Practical Rules for Using Color in Charts"](http://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf).
## Scales
- ``scale_color_solarized``: [Solarized](http://ethanschoonover.com/solarized) colors
- ``scale_color_economist``: colors used in plots in plots in *The Economist*.
- ``scale_color_stata``, ``scale_shapes_stata``, ``scale_linetype_stata``: color, shape, and linetype palettes from Stata graph schemes.
- ``scale_color_excel10``: colors from new and old Excel.
- ``scale_color_tableau``, ``scale_shape_tableau``: color and shape palettes from [Tableau](http://www.tableausoftware.com/).
- ``scale_shape_cleveland``, ``scale_shape_tremmel``, ``scale_shape_circlefill``: shape scales from classic works in visual perception: Cleveland,
Tremmel (1995), and Lewandowsky and Spence (1989).
- ``scale_color_few``: color palettes from Stephen Few's ["Practical Rules for Using Color in Charts"](http://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf).
- ``scale_color_colorblind``: Colorblind safe palette from
http://jfly.iam.u-tokyo.ac.jp/color/.
# Install
To install the stable version from CRAN,
```r
install.packages('ggthemes', dependencies = TRUE)
```
Or, to install the development version from github, use the
**devtools** package,
```r
library("devtools")
install_github("ggthemes", "jrnold")
```
Windows users also must first install
[Rtools](http://cran.rstudio.com/bin/windows/Rtools/).
# Contribute
Contributions are welcome! If you would like to add a theme, scales,
etc., fork the repository, add your theme, and submit a pull request.
# Examples
```{r dsamp}
library("ggplot2")
library("ggthemes")
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
```
## Tufte theme and geoms
Minimal theme and geoms based on plots in *The Visual Display of
Quantitative Information*.
```{r tufte-rangeframe}
(ggplot(mtcars, aes(wt, mpg))
+ geom_point() + geom_rangeframe()
+ theme_tufte())
```
The Tufte minimal boxplot.
```{r tufteboxplot}
(ggplot(mtcars, aes(factor(cyl), mpg))
+ theme_tufte(ticks=FALSE)
+ geom_tufteboxplot())
```
## Economist theme
A theme that approximates the style of plots in The Economist
magazine.
```{r economist}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_economist()
+ scale_colour_economist()
+ ggtitle("Diamonds Are Forever"))
```
## Solarized theme
A theme and color and fill scales based on the Solarized palette.
The light theme.
```{r solarized-light}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_solarized()
+ scale_colour_solarized("blue"))
```
The dark theme.
```{r solarized-dark}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_solarized(light=FALSE)
+ scale_colour_solarized("red"))
```
## Stata theme
Themes and scales (color, fill, linetype, shapes) based on the graph
schemes in Stata.
```{r stata}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_stata()
+ scale_colour_stata()
+ ggtitle("Plot Title"))
```
## Excel 2003 theme
For that classic ugly look and feel. For ironic purposes only. 3D bars
and pies not included. Please never use this theme.
```{r excel1}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_excel()
+ scale_colour_excel())
```
```{r excel2}
(ggplot(diamonds, aes(clarity, fill=cut))
+ geom_bar()
+ scale_fill_excel()
+ theme_excel())
```
## Inverse Gray Theme
Inverse of `theme_gray`, i.e. white plot area and gray background.
```{r igray}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_igray())
```
## Tableau Scales
Color, fill, and shape scales based on those used in the Tableau softare.
```{r tableau}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_igray()
+ scale_colour_tableau())
```
```{r tableau-colorbind10}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_igray()
+ scale_colour_tableau("colorblind10"))
```
## Stephen Few's Practical Rules for Using Color ...
Color palette and theme based on Stephen Few's ["Practical Rules for Using Color in Charts"](http://www.perceptualedge.com/articles/visual_business_intelligence/rules_for_using_color.pdf).
```{r few}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_few()
+ scale_colour_few())
```
## Wall Street Journal
Theme and some color palettes based on plots in the *The Wall Street Journal*.
```{r wsj}
(qplot(carat, price, data=dsamp, colour=cut)
+ theme_wsj()
+ scale_colour_wsj("colors6", "")
+ ggtitle("Diamond Prices"))
```