Description Usage Arguments Value Author(s) See Also Examples
Use system pdflatex
(*NIX only) to compile tikz output.
pdftikz
will save the current directory, change
to the directory of the filename and execute pdflatex on the
tikz output to produce a pdf file
1 | pdftikz(filename)
|
filename |
|
output of tryCatch
block
Thomas P. Harte
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # reproduce cover PDF from:
# https://cran.r-project.org/web/packages/tikzDevice/vignettes/tikzDevice.pdf
d<- tempdir()
filename<- file.path(d, 'cover-pdf.tex')
require(tikzDevice)
tikz(file=filename, width=4, height=4, standAlone=TRUE)
par(las=1)
x <- seq(-4.5,4.5,length.out=100)
y <- dnorm(x)
xi <- seq(-2,2,length.out=30)
yi <- dnorm(xi)
plot(x,y,type='l',col='blue',ylab='$p(x)$',xlab='$x$')
lines(xi,yi,type='s')
lines(range(xi),c(0,0))
lines(xi,yi,type='h')
title(main="$p(x)=\\frac{1}{\\sqrt{2\\pi}}e^{-\\frac{x^2}{2}}$")
int <- integrate(dnorm,min(xi),max(xi),subdivisions=length(xi))
text(2.8, 0.35,
paste(
"\\small$\\displaystyle\\int_{",min(xi),"}^{",max(xi),"}p(x)dx",
"\\approx", round(int[['value']], 3), '$',
sep=''
)
)
dev.off()
pdftikz(filename)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.