---
title: "vangogh"
author: "Cheryl Isabella"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{vignette}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "figure/",
  fig.height = 1
)
```
# Vincent van Gogh Color Palettes

## Introduction
The vangogh package (for use in R) consist of color scales extracted by Cheryl Isabella from a selection of Vincent van Gogh's paintings.

## Installation

```r
install.packages("vangogh")
```

__Or the development version__

``` r
devtools::install_github("cherylisabella/vangogh")
```

## Usage
```{r, palettes_dummy}
library("vangogh")

# See all palettes
names(vangogh_palettes)

# See all functions
lsf.str("package:vangogh")
```

## Palettes and their associated artworks

### The Starry Night (1889)

```{r, StarryNight}
vangogh_palette("StarryNight")
```

### Starry Night Over the Rhône / La Nuit étoilée (1888)

```{r, StarryRhone}
vangogh_palette("StarryRhone")
```

### Self-portrait (1889)

```{r, SelfPortrait}
vangogh_palette("SelfPortrait")
```

### Café Terrace at Night (1888)

```{r, CafeTerrace}
vangogh_palette("CafeTerrace")
```

### The Church at Auvers (1890)

```{r, Eglise}
vangogh_palette("Eglise")
```

### Irises / Les Iris (1889)

```{r, Irises}
vangogh_palette("Irises")
```

### Sunflowers - Munich version (1888)

```{r, SunflowersMunich}
vangogh_palette("SunflowersMunich")
```

### Sunflowers - London version (1888)

```{r, SunflowersLondon}
vangogh_palette("SunflowersLondon")
```

### Noon – Rest from Work (1890)

```{r, Rest}
vangogh_palette("Rest")
```

### Bedroom in Arles / Slaapkamer te Arles (1888)

```{r, Bedroom}
vangogh_palette("Bedroom")
```

### The Night Café / Le Café de nuit (1888)

```{r, CafeDeNuit}
vangogh_palette("CafeDeNuit")
```

### Van Gogh's Chair (1888)

```{r, Chaise}
vangogh_palette("Chaise")
```

### Shoes (1886)

```{r, Shoes}
vangogh_palette("Shoes")
```

### Landscape with Houses (1890)

```{r, Landscape}
vangogh_palette("Landscape")
```

### Wheat Field with Cypresses (1889)

```{r, Cypresses}
vangogh_palette("Cypresses")
```


## Examples

### Discrete palette examples using ggplot2

```{r}
library("ggplot2")
ggplot(mtcars, aes(factor(cyl), fill=factor(vs))) +  geom_bar() +
  scale_fill_manual(values = vangogh_palette("SelfPortrait")) 

ggplot(mtcars, aes(mpg, disp)) + 
  geom_point(aes(col = factor(gear)), size = 4) + 
  scale_color_manual(values = vangogh_palette("Cypresses"))

ggplot(iris) + 
    aes(Sepal.Length, Sepal.Width, color = Species) + 
    geom_point(size = 3) + 
    scale_color_manual(values = vangogh_palette("CafeDeNuit"))
```

- Discrete palettes pick 1:n colors from the palette vector (n=5 for this package as 5 colors were curated for each palette)

- Default color selection starts from colors at the extreme left and ends at the extreme right of the color palette.

### Continuous palette examples

#### Generate a continuous palette from the given discrete palettes
```{r}
x <- vangogh_palette("Chaise", 1000, "continuous")
x
```

- `colorRampPalette()`is used to a set of colors to create a new continuous palette.

#### Heatmap examples
```{r}
oldpar <- par(mar = c(1, 1, 1, 1))
par(mar = c(1, 1, 1, 1))
pal <- vangogh_palette("SunflowersLondon", 21, type = "continuous")
image(volcano, col = pal)
par(oldpar)
```

```{r}
ggplot(faithfuld) +
  aes(waiting, eruptions, fill = density) + 
  geom_tile() + 
  scale_color_manual(values = vangogh_palette("CafeTerrace")) 
```


### scale_colour_vangogh() and scale_fill_vangogh() examples

```{r}
ggplot(data = mpg) +
   geom_point(mapping = aes(x = displ, y = hwy, color = class)) +
   scale_colour_vangogh(palette="StarryRhone")

ggplot(diamonds) + geom_bar(aes(x = cut, fill = clarity)) +
   scale_fill_vangogh(palette = "StarryNight")
```




