label_tex: A labeller function to parse TeX syntax

View source: R/labeller.R

label_texR Documentation

A labeller function to parse TeX syntax

Description

This function formats the strip labels of facet grids and wraps that contains TeX expressions. The latex2exp package must be installed.

Usage

label_tex(labels, ...)

Arguments

labels

Data frame of labels. Usually contains only one element, but faceting over multiple factors entails multiple label variables.

...

Arguments passed on to ggplot2::label_parsed

multi_line

Whether to display the labels of multiple factors on separate lines.

See Also

ggplot2::labeller, latex2exp::TeX()

Examples

# requires latex2exp package be installed
if (requireNamespace("latex2exp", quietly = TRUE)) {
  library(ggplot2)
  d <- data.frame(x = 1, y = 1, facet = "$\\beta$")
  ggplot(d, aes(x, y)) +
    geom_point() +
    facet_wrap(~ facet, labeller = label_tex)
}

ggforce documentation built on May 29, 2024, 1:34 a.m.