# Exercises

```{r }
library(tidyverse)
theme_set(theme_bw())

library(RColorBrewer)
```

Consider this dataset:

```{r}
diamonds
```

## Scatter plots

Make a scatter plot of `carat` and `price`

```{r}

```

Make a scatter plot of `carat` and `price`` with `alpha = 0.5` and save that to a variable called `p`

```{r}

```

Make price axis more readable (hint: `scale_y_continuous(labels = scales::comma)`)

```{r}

```

Use a log10 scale on both axes (hint: `scale_...`)

```{r}

```

Try to make axes prettier (hint: http://ggplot2.tidyverse.org/reference/annotation_logticks.html)

```{r}

```

## Bar plots

Make a barplot of `cut`

```{r}

```

Make a barplot of `cut` with fill by `color` (use default position stacked)

```{r}

```

Make a barplot of `cut` with fill by `color` with `position_dodge()`

```{r}

```

Make a barplot of `color` with fill by `cut`

```{r}

```

Try another color scheme (from `RColorBrewer`); use http://colorbrewer2.org/ to pick one (e.g. `Set1`), 
also see https://cran.r-project.org/package=viridis and 
http://statmath.wu.ac.at/~zeileis/papers/Zeileis+Hornik+Murrell-2009.pdf .

```{r}

```

Choose colors manually (hint: `scale_fill_manual(values = c("Fair" = "blue", ...))`)

```{r}

```

## Histograms

Make a histogram of `price`

```{r}

```

## Density plots

Make a boxplot of `price` for each `color`

```{r}

```

Make a violin plot (with quantiles 25%, 50% and 75%) of `price` for each `color` (also fill by `color`)

```{r}

```

Read `?geom_hex` and try to use that function for `carat`/`price` instead of a scatter plot

```{r}

```

## Facetting

Make a histogram of `price` for each level of `cut`

```{r}

```

Make a scatter plot of `carat` and `price` for each level of `cut` and `color`

```{r}

```

Make a scatter plot of `carat` and `price` for each level of `cut` and `color` with `alpha = 0.1` and coloured by `clarity` with `YlGnBu` palette 

```{r}

```

...add pretty log scales

```{r}

```

Add a title and subtitle (hint: `labs()`)

```{r}

```

## Beautiful plot

Create the most beautiful plot you can using the `diamonds` dataset.

```{r}

```
