graph2pdffile: Creates a pdf file by converting a graph to tikz and...

View source: R/graphtikzcode.R

graph2pdffileR Documentation

Creates a pdf file by converting a graph to tikz and lualatexing the output

Description

Based on tikzDevice::tikz.

Usage

graph2pdffile(
  texte,
  output = tempfile(fileext = ".pdf"),
  widthe = 7,
  heighte = 7,
  caption = NULL,
  label = NULL,
  addfigureenv = FALSE,
  sanitize = FALSE,
  modify = NULL,
  addtopreamble = NULL,
  texcompiler = "lualatex",
  ...
)

Arguments

texte

file containing tikz code

output

output fill path (will be overwritten if existing with no warning)

widthe

a numeric

heighte

a numeric

caption

a character string.

label

a character string.

addfigureenv

a boolean

sanitize

a booleaan

modify

a function that takes a character string as a parameter and returns a character string

...

additional parameters to pass to tikzDevice::tikz

usepackages

a character string

Examples

## First example: we generate the tikz code for a graph. 

outputpdffile<-tempfile(fileext = ".pdf")
command="print(ggplot2::ggplot(data=cars,ggplot2::aes(x=speed,y=dist))+ggplot2::geom_point())"
graph2pdffile(command,output=outputpdffile)
readLines(outputpdffile)
fs::file_show(outputpdffile)
graph2pdffile(command,output=outputpdffile,widthe=7,heighte=3)
fs::file_show(outputpdffile)
command="print(ggplot2::ggplot(data=cars,ggplot2::aes(x=speed,y=dist,color=dist))+
ggplot2::geom_point())"
fs::file_show(graph2pdffile(command,widthe=7,heighte=3,modify=function(y){
gsub("dist","$\\frac{1-\\exp\\left(-\\mathrm(x)^2\\right)}{\\sin(\\mathrm{x})+\\mathds{1}_{\\{0\\}}(\\mathrm{x})}$",y)}))

DanielBonnery/SweaveLst documentation built on May 4, 2022, 11:45 p.m.