View source: R/ggplot2-integration.R
| element_latex | R Documentation |
Use this as a theme element for axis titles, axis labels, plot titles, or any other text element in a ggplot2 theme. The text string is parsed as LaTeX math and rendered via MicroTeX.
element_latex(
math_font = "",
fontsize = NULL,
lineheight = 1.2,
max_width = 0,
input_mode = c("mixed", "math"),
render_mode = c("typeface", "path"),
...
)
math_font |
Name of the math font to use (e.g., |
fontsize |
Convenience alias for |
lineheight |
Multi-line height multiplier (default 1.2), matching
|
max_width |
Numeric maximum width in big points for automatic
line wrapping. Use |
input_mode |
How |
render_mode |
Character string: |
... |
Additional arguments passed to |
Dollar signs ($...$) in the label text are stripped automatically
so that both "\frac{a}{b}" and "$\frac{a}{b}$" work.
This element is an S7 subclass of ggplot2::element_text, so it
inherits all standard text properties (size, colour, hjust, etc.) from
the theme and supports merge_element() correctly.
An S7 object of class element_latex, inheriting from
ggplot2::element_text.
if (requireNamespace("ggplot2", quietly = TRUE)) {
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) + geom_point() +
labs(x = "$\\beta_1 \\cdot x + \\beta_0$") +
theme(axis.title.x = element_latex())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.