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())`

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

if (FALSE) 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))
#> Error in ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)): could not find function "ggplot"
 # \dontrun{}