Save ggplot Figure to TeX Snippet
fig2tex.Rd
Creates two files (.tex and .png); the .png file contains the figure (ggplot) that is submitted and the .tex file contains the snipped to load the figure use (\inputfile.tex in your TeX document) to include the figure with the caption.
Arguments
- g
figure of class ggplot
- fileGraph
file name to save figure
- caption
caption for figure
- ...
parameters passed to ggsave() such as dpi,width
Examples
q = tempdir()
x=seq(-10,10,0.1); y=x^2-2
g = ggplot2::ggplot(data.frame(x,y), ggplot2::aes(x,y)) +
ggplot2::geom_point(col='red') + ggplot2::theme_bw()
fig2tex(g, file.path(q,"test.png"), "First Graph.")
#> Saving 6.67 x 6.67 in image
#> [1] "/var/folders/bz/zk25f6614w5b3_f61czs2dtc0000gr/T//Rtmp0kPlGw/test.tex"