View source: R/render_ggplot_to_latex.R
render_ggplot_to_latex | R Documentation |
This function exports a ggplot figure to a specified path in TikZ format and wraps it in a LaTeX figure environment.
render_ggplot_to_latex(
fig = NULL,
fig_path = NULL,
sanitize = TRUE,
width = 6.4,
height = 3.54,
fig_out = NULL,
title = NULL,
caption = NULL,
label = NULL,
copy_fig = TRUE
)
fig |
A ggplot object to be exported. Must not be NULL. |
fig_path |
A character string specifying the path where the figure will be saved. Must not be NULL. |
sanitize |
A logical indicating whether to sanitize the figure. Default is TRUE. |
width |
A numeric value specifying the width of the figure. Default is 6.4. |
height |
A numeric value specifying the height of the figure. Default is 3.54. |
fig_out |
A character string specifying the output path for the wrapped figure. Optional. |
title |
A character string for the figure title. Optional. |
caption |
A character string for the figure caption. Optional. |
label |
A character string for the figure label. Optional. |
copy_fig |
A logical indicating whether to copy the figure to the clipboard. Default is TRUE. |
The original ggplot object, invisibly returned.
## Not run:
library(ggplot2)
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
render_ggplot_to_latex(fig = p, fig_path = "path/to/figure.tex",
title = "Car Weight vs MPG", caption = "A scatter plot.",
label = "fig:car_weight")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.