Skip to content

Commit a3b797a

Browse files
committedMar 7, 2017
optimize vignette
1 parent 4495390 commit a3b797a

File tree

1 file changed

+21
-41
lines changed

1 file changed

+21
-41
lines changed
 

‎vignettes/ggsci.Rmd

+21-41
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ p2 = ggplot(subset(diamonds, carat > 2.2 & depth > 55 & depth < 70),
114114

115115
## NPG
116116

117-
The NPG palette is inspired by the plots in journals published by Nature Publishing Group:
117+
The NPG palette is inspired by the plots in journals published by
118+
Nature Publishing Group:
118119

119120
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
120121
p1_npg = p1 + scale_color_npg()
@@ -124,8 +125,8 @@ grid.arrange(p1_npg, p2_npg, ncol = 2)
124125

125126
## AAAS
126127

127-
The AAAS palette is inspired by the plots in journals published by American Association
128-
for the Advancement of Science:
128+
The AAAS palette is inspired by the plots in journals published by
129+
American Association for the Advancement of Science:
129130

130131
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
131132
p1_aaas = p1 + scale_color_aaas()
@@ -135,7 +136,8 @@ grid.arrange(p1_aaas, p2_aaas, ncol = 2)
135136

136137
## NEJM
137138

138-
The NEJM palette is inspired by the plots in <emph>The New England Journal of Medicine</emph>:
139+
The NEJM palette is inspired by the plots in
140+
<emph>The New England Journal of Medicine</emph>:
139141

140142
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
141143
p1_nejm = p1 + scale_color_nejm()
@@ -145,7 +147,8 @@ grid.arrange(p1_nejm, p2_nejm, ncol = 2)
145147

146148
## Lancet
147149

148-
The Lancet palette is inspired by the plots in Lancet journals, such as <emph>Lancet Oncology</emph>:
150+
The Lancet palette is inspired by the plots in Lancet journals, such as
151+
<emph>Lancet Oncology</emph>:
149152

150153
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
151154
p1_lancet = p1 + scale_color_lancet()
@@ -155,7 +158,8 @@ grid.arrange(p1_lancet, p2_lancet, ncol = 2)
155158

156159
## JCO
157160

158-
The JCO palette is inspired by the the plots in <emph>Journal of Clinical Oncology</emph>:
161+
The JCO palette is inspired by the the plots in
162+
<emph>Journal of Clinical Oncology</emph>:
159163

160164
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
161165
p1_jco = p1 + scale_color_jco()
@@ -183,22 +187,10 @@ The D3 palette is from the categorical colors used by
183187
There are four palette types (`category10`, `category20`,
184188
`category20b`, `category20c`) available.
185189

186-
```{r, fig.width = 10.67, fig.height = 16, out.width = 800, out.height = 1200, dpi = 150}
190+
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
187191
p1_d3 = p1 + scale_color_d3()
188192
p2_d3 = p2 + scale_fill_d3()
189-
p1_d3_c10 = p1 + scale_color_d3("category10")
190-
p2_d3_c10 = p2 + scale_fill_d3("category10")
191-
p1_d3_c20 = p1 + scale_color_d3("category20")
192-
p2_d3_c20 = p2 + scale_fill_d3("category20")
193-
p1_d3_c20b = p1 + scale_color_d3("category20b")
194-
p2_d3_c20b = p2 + scale_fill_d3("category20b")
195-
p1_d3_c20c = p1 + scale_color_d3("category20c")
196-
p2_d3_c20c = p2 + scale_fill_d3("category20c")
197-
grid.arrange(p1_d3_c10, p2_d3_c10,
198-
p1_d3_c20, p2_d3_c20,
199-
p1_d3_c20b, p2_d3_c20b,
200-
p1_d3_c20c, p2_d3_c20c,
201-
ncol = 2, nrow = 4)
193+
grid.arrange(p1_d3, p2_d3, ncol = 2)
202194
```
203195

204196
## LocusZoom
@@ -219,36 +211,23 @@ The IGV palette is from the colors used by
219211
for representing chromosomes. There are two palette types
220212
(`default`, `alternating`) available.
221213

222-
```{r, fig.width = 10.67, fig.height = 8, out.width = 800, out.height = 600, dpi = 150}
214+
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
223215
p1_igv_default = p1 + scale_color_igv()
224216
p2_igv_default = p2 + scale_fill_igv()
225-
p1_igv_alternate = p1 + scale_colour_manual(
226-
values = rep(pal_igv("alternating")(2), times = 3))
227-
p2_igv_alternate = p2 + scale_fill_manual(
228-
values = rep(pal_igv("alternating")(2), times = 3))
229-
grid.arrange(p1_igv_default, p2_igv_default,
230-
p1_igv_alternate, p2_igv_alternate,
231-
ncol = 2, nrow = 2)
217+
grid.arrange(p1_igv_default, p2_igv_default, ncol = 2)
232218
```
233219

234220
## UChicago
235221

236222
The UChicago palette is based on
237223
[the colors](http://communications.uchicago.edu/identity/color-palette)
238-
used by The University of Chicago.
239-
There are three palette types (`default`, `light`, `dark`) available.
224+
used by The University of Chicago. There are three palette types
225+
(`default`, `light`, `dark`) available.
240226

241-
```{r, fig.width = 10.67, fig.height = 12, out.width = 800, out.height = 900, dpi = 150}
227+
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
242228
p1_uchicago = p1 + scale_color_uchicago()
243229
p2_uchicago = p2 + scale_fill_uchicago()
244-
p1_uchicago_light = p1 + scale_color_uchicago("light")
245-
p2_uchicago_light = p2 + scale_fill_uchicago("light")
246-
p1_uchicago_dark = p1 + scale_color_uchicago("dark")
247-
p2_uchicago_dark = p2 + scale_fill_uchicago("dark")
248-
grid.arrange(p1_uchicago, p2_uchicago,
249-
p1_uchicago_light, p2_uchicago_light,
250-
p1_uchicago_dark, p2_uchicago_dark,
251-
ncol = 2, nrow = 3)
230+
grid.arrange(p1_uchicago, p2_uchicago, ncol = 2)
252231
```
253232

254233
## Star Trek
@@ -283,7 +262,8 @@ grid.arrange(p1_rickandmorty, p2_rickandmorty, ncol = 2)
283262

284263
## The Simpsons
285264

286-
This palette is inspired by the colors used in the TV show <emph>The Simpsons</emph>:
265+
This palette is inspired by the colors used in the TV show
266+
<emph>The Simpsons</emph>:
287267

288268
```{r, fig.width = 10.67, fig.height = 4, out.width = 800, out.height = 300, dpi = 150}
289269
p1_simpsons = p1 + scale_color_simpsons()
@@ -300,7 +280,7 @@ to demonstrate the continuous color palettes in `ggsci`.
300280
library("reshape2")
301281
302282
data("mtcars")
303-
cor = cor(mtcars)
283+
cor = cor(unname(cbind(mtcars, mtcars, mtcars, mtcars)))
304284
cor_melt = melt(cor)
305285
306286
p3 = ggplot(cor_melt,

0 commit comments

Comments
 (0)
Please sign in to comment.