fig2tex: Save ggplot Figure to TeX Snippet

View source: R/fig2tex.R

fig2texR Documentation

Save ggplot Figure to TeX Snippet

Description

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.

Usage

fig2tex(g, fileGraph, 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

Author(s)

Thomas Gredig

See Also

raw.texArticle

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.")


thomasgredig/RAWdataR documentation built on Nov. 6, 2024, 9:46 a.m.