colour_text: Create the css needed to colour text using ggtext

View source: R/legend_helpers.R

colour_textR Documentation

Create the css needed to colour text using ggtext

Description

This is a helper function to wrap the css to make text certain colours. This will be useful when making grattan charts. This should be used within 'ggtext::geom_richtext()' or if being used in a sub-title or title it should be used in the 'labs()' call together with 'theme(plot.subtitle = element_markdown())'

Usage

colour_text(colour, text, is_note = FALSE, bold_labs = TRUE)

Arguments

colour

(a character) the colour you want to colour text

text

(a character) what the coloured text should say

is_note

(logical; default = FALSE) is it a note?

bold_labs

(logical; default = TRUE) should the labels be bolded?

Value

(a glue)

Examples

## Not run: library(ggtext)

ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point(size = 3) +
    labs(
        title = glue::glue("**Fisher's *Iris* dataset**
            <span style='font-size:11pt'>Sepal width vs. sepal length for
                                   {colour_text('#0072B2','setosa')}
                                   {colour_text('#D55E00','versicolor')}
                                   {colour_text('#009E73','virginica')}
                                       </span>"),
                                         theme(plot.title = element_markdown(lineheight = 1.1) )

## End(Not run)

MattCowgill/grattantheme documentation built on Jan. 13, 2023, 11:02 a.m.