---
title: "Specifying Colours"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Specifying Colours}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(ggplot2)
library(emphatic)
```

```{r setup}
library(ggplot2)
library(emphatic)
```

```{r}
test_df <- head(mtcars, 10)
```



Specify a single colour
------------------------------------------------------------------------------

```{r}
test_df |>
  hl('skyblue')
```

Specify a vector of colours
------------------------------------------------------------------------------

```{r}
test_df |>
  hl(c('skyblue', 'hotpink', '#445566'))
```

Specify a colour scale to apply to a variable
------------------------------------------------------------------------------

```{r}
test_df |>
  hl(ggplot2::scale_colour_viridis_c(), cols = disp)
```


Specify a colour scale to apply to a variable, and apply the colouring to multiple columns
------------------------------------------------------------------------------

The colourscale is calibrated against only the variable `disp`, but the colouring
is applied to multiple columns.

```{r}
test_df |>
  hl(ggplot2::scale_colour_viridis_c(), cols = disp, scale_apply = mpg:drat)
```


Specify a colour scale to apply to multiple variables independently
------------------------------------------------------------------------------

```{r}
test_df |>
  hl(ggplot2::scale_colour_viridis_c(), cols = mpg, show_legend = TRUE) |>
  hl(ggplot2::scale_colour_viridis_c(), cols = disp, show_legend = TRUE)
```


Specify a colour scale to apply to multiple variables as a whole
------------------------------------------------------------------------------

The scale is calibrated against all data in the nominated `cols`

```{r}
test_df |>
  hl(ggplot2::scale_colour_viridis_c(), cols = c(wt, gear, carb), show_legend = TRUE) 
```




















