Styled text and formula theme elements

element_markup.RdUse these elements in the slots that draw a label, for example plot.title, axis.title.x, axis.text.y, legend.text or strip.text.x. Standard font properties and margins inherit from the enclosing theme. Each label is shaped and measured separately. Numeric tick positions stay unchanged.
Usage
element_markup(
...,
format = "markdown",
width = NULL,
lang = NULL,
text_direction = "auto",
align = "left",
paragraph_spacing = 0
)
element_formula(...)Arguments
- ...
Arguments passed to ggplot2::element_text().
- format
Input grammar. Use
"plain"for literal text,"markdown"for the documented markup subset, or"mixed"for markup with plotmath. In mixed mode a matched pair of single dollar signs encloses an inline expression. A display expression occupies its own block.- width
Optional scalar grid unit for language-aware line wrapping.
- lang
Optional ICU locale or BCP 47 language tag for line breaks.
- text_direction
Base reading direction, auto, ltr or rtl.
- align
Alignment of lines, one of left, center and right.
- paragraph_spacing
Additional space between paragraphs, in big points.
Examples
ggplot2::theme(plot.title = element_markup(face = "bold"))
#> <theme>List of 1
#> $ plot.title: <ggforma::forma_text_element>
#> ..@ family : NULL
#> ..@ face : chr "bold"
#> ..@ italic : chr NA
#> ..@ fontweight : num NA
#> ..@ fontwidth : num NA
#> ..@ colour : NULL
#> ..@ size : NULL
#> ..@ hjust : NULL
#> ..@ vjust : NULL
#> ..@ angle : NULL
#> ..@ lineheight : NULL
#> ..@ margin : NULL
#> ..@ debug : NULL
#> ..@ inherit.blank: logi FALSE
#> ..@ forma_options: List of 6
#> .. .. $ format : chr "markdown"
#> .. .. $ width : NULL
#> .. .. $ lang : NULL
#> .. .. $ align : chr "left"
#> .. .. $ paragraph_spacing: num 0
#> .. .. $ text_direction : chr "auto"
#> - attr(*, "class")= chr "gg"
#> @ complete: logi FALSE
#> @ validate: logi TRUE
ggplot2::ggplot(mtcars, ggplot2::aes(wt, mpg)) +
ggplot2::geom_point() + ggplot2::labs(y = "frac(miles, gallons)") +
ggplot2::theme(axis.title.y = element_formula())