knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(ggplot2)
library(emphatic)
library(ggplot2)
library(emphatic)
test_df <- head(mtcars, 10)

Specify a single colour

test_df |>
  hl('skyblue')

Specify a vector of colours

test_df |>
  hl(c('skyblue', 'hotpink', '#445566'))

Specify a colour scale to apply to a variable

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.

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

Specify a colour scale to apply to multiple variables independently

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

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


coolbutuseless/emphatic documentation built on Dec. 27, 2024, 1:18 a.m.