View source: R/legend_helpers.R
colour_text | R Documentation |
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)
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? |
(a glue)
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.