View source: R/graphtikzcode.R
graph2pdffile | R Documentation |
Based on tikzDevice::tikz.
graph2pdffile( texte, output = tempfile(fileext = ".pdf"), widthe = 7, heighte = 7, caption = NULL, label = NULL, addfigureenv = FALSE, sanitize = FALSE, modify = NULL, addtopreamble = NULL, texcompiler = "lualatex", ... )
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 |
## 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)}))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.