-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
334 lines (249 loc) · 7.72 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# paintingr
<!-- badges: start -->
<!-- badges: end -->
> "The greatest value of a picture is when it forces us to notice what we never expected to see." - John Tukey
Color is one of the most important attributes of a figure. Dedicated choice of color can help us deliver our idea more vividly.
------------------------------------------------------------------------
The goal of `paintingr` is to provide a set of palettes from paintings.
Structure of the package was based on coding from the [wesanderson](https://github.com/karthik/wesanderson) packages.
## Installation
You can install the `paintingr` with:
```{r,eval=FALSE}
install.packages('paintingr')
```
Or the development version from [GitHub](https://github.com/) with:
```{r,eval=FALSE}
# install.packages("devtools")
devtools::install_github("thereallda/paintingr")
```
## Usage
```{r }
library(paintingr)
# display all palettes
display_all_palettes()
```
## Palettes
```{r, include=FALSE}
library(imager)
```
### Pearlgirl
Girl with a Pearl Earring - Johannes Vermeer (1665), [Source](https://www.mauritshuis.nl/en/our-collection/artworks/670-girl-with-a-pearl-earring/)
```{r, eval=FALSE}
paint_palette("Pearlgirl")
```
```{r, echo=FALSE}
paint <- load.image("img/Girl_with_a_Pearl_Earring.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Pearlgirl")
```
### Splash
A Bigger Splash - David Hockney (1967), [Source](https://www.tate.org.uk/art/artworks/hockney-a-bigger-splash-t03254)
```{r, eval=FALSE}
paint_palette("Splash")
```
```{r, echo=FALSE}
paint <- load.image("img/A_Bigger_Splash_David_Hockney.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Splash")
```
### Autumn
Autumn at Oirase - Kawase Hasui (1933), [Source](https://www.pepperholm.com/products/autumn-at-oirase)
```{r, eval=FALSE}
paint_palette("Autumn")
```
```{r, echo=FALSE}
paint <- load.image("img/autumn-at-oirase.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Autumn")
```
### Villeneuve
Matin à Villeneuve - Henri Biva (1905), [Source](https://en.wikipedia.org/wiki/Matin_%C3%A0_Villeneuve)
```{r, eval=FALSE}
paint_palette("Villeneuve")
```
```{r, echo=FALSE}
paint <- load.image("img/Villeneuve.jpeg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Villeneuve")
```
### Ophelia
Ophelia - John Everett Millais (1851-1852), [Source](https://www.tate.org.uk/art/artworks/millais-ophelia-n01506)
```{r, eval=FALSE}
paint_palette("Ophelia")
```
```{r, echo=FALSE}
paint <- load.image("img/John_Everett_Millais-Ophelia.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Ophelia")
```
### Kitchen
Kitchen (Detail 2) - Liza Lou (1991–1996), [Source](https://whitney.org/collection/works/34855)
```{r, eval=FALSE}
paint_palette("Kitchen")
```
```{r, echo=FALSE}
paint <- load.image("img/kitchendetail2.jpeg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Kitchen")
```
### Spring
SPRING BY THE SEINE - Claude Monet (1875), [Source](https://www.mcgawgraphics.com/products/claude-monet-spring-by-the-seine-1875)
```{r, eval=FALSE}
paint_palette("Spring")
```
```{r, echo=FALSE}
paint <- load.image("img/spring-by-the-seine-oscar-claude-monet.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Spring")
```
### Strawberries
Strawberries - Édouard Manet (1882), [Source](https://www.metmuseum.org/art/collection/search/436963)
```{r, eval=FALSE}
paint_palette("Strawberries")
```
```{r, echo=FALSE}
paint <- load.image("img/Strawberries_Edouard_Manet.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Strawberries")
```
### Seascape
Seascape at Saintes-Maries - Vincent van Gogh (1888), [Source](https://en.wikipedia.org/wiki/Saintes-Maries_(Van_Gogh_series))
```{r, eval=FALSE}
paint_palette("Seascape")
```
```{r, echo=FALSE}
paint <- load.image("img/Seascape_at_Saintes-Maries.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Seascape")
```
### Twilight
Twilight, Venice - Claude Monet (1908), [Source](https://commons.wikimedia.org/wiki/File:Claude_Monet_-_Twilight,_Venice.jpg)
```{r, eval=FALSE}
paint_palette("Twilight")
```
```{r, echo=FALSE}
paint <- load.image("img/Venice_Twilight.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Twilight")
```
### Abstract
Abstract Composition - Jessica Dismorr (1915), [Source](https://www.tate.org.uk/art/artworks/dismorr-abstract-composition-t01084)
```{r, eval=FALSE}
paint_palette("Abstract")
```
```{r, echo=FALSE}
paint <- load.image("img/T01084_10.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Abstract")
```
### Vesuivus
Vesuvius in Eruption - Joseph Wright of Derby (1776-1780), [Source](https://www.bl.uk/collection-items/vesuvius-in-eruption)
```{r, eval=FALSE}
paint_palette("Vesuvius")
```
```{r, echo=FALSE}
paint <- load.image("img/Vesuvius_in_Eruption.jpg")
par(mai=rep(0,4))
layout(matrix(c(1,1,2,2),byrow = TRUE), heights=c(6,1))
plot(paint,axes=FALSE,xlab="",ylab="")
paint_palette("Vesuvius")
```
## Examples
`ggplot2`-based examples
### Heatmap
Use `type="continuous"` to automatically interpolate between colors if you want more colors than the palette can offer (n \> 5/6).
```{r, warning=FALSE}
library(ggplot2)
# Dummy data
x <- LETTERS[1:20]
y <- paste0("var", seq(1,20))
data <- expand.grid(X=x, Y=y)
data$Z <- seq(1,20)+runif(400, 0, 5)
# Heatmap
pal <- paint_palette("Autumn", n=100, type="continuous")
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = pal) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()
```
```{r}
# Heatmap with palette of "Vesuvius"
pal2 <- paint_palette("Vesuvius", n=100, type="continuous")
ggplot(data, aes(X, Y, fill= Z)) +
geom_tile() +
scale_fill_gradientn(colours = pal2) +
scale_x_discrete(expand = c(0, 0)) +
scale_y_discrete(expand = c(0, 0)) +
coord_equal()
```
### Boxplot
```{r}
# use iris data from `ggplot2` for demonstration
data(iris)
ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot(aes(fill = Species)) +
theme_classic() +
theme(legend.position = "top") +
scale_fill_manual(values = paint_palette("Villeneuve"))
```
### Scatter
```{r}
# Scatter
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point(aes(color = Species)) +
theme_classic() +
theme(legend.position = "top") +
scale_color_manual(values = paint_palette("Kitchen"))
```
### Violin plot
```{r}
data(mpg)
# violin plot with 7 colors, Spring palette only have six colors add one more
ggplot(mpg, aes(x=class, y=hwy, fill=class)) +
geom_violin() +
theme_classic() +
scale_fill_manual(values = c(paint_palette("Spring", n=6), "black"))
```
### Barplot
```{r}
ggplot(mpg, aes(x = class, fill = drv)) +
geom_bar() +
theme_classic() +
scale_fill_manual(values = paint_palette("Ophelia"))
```