| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/hooks-html.R, R/hooks-asciidoc.R, |
| 3 |
% R/hooks-latex.R, R/hooks-md.R, R/hooks-rst.R, R/hooks-textile.R |
| 4 |
\name{hook_plot_html} |
| 5 |
\alias{hook_plot_html} |
| 6 |
\alias{hook_plot_asciidoc} |
| 7 |
\alias{hook_plot_tex} |
| 8 |
\alias{hook_plot_md} |
| 9 |
\alias{hook_plot_rst} |
| 10 |
\alias{hook_plot_textile} |
| 11 |
\title{Default plot hooks for different output formats} |
| 12 |
\usage{ |
| 13 |
hook_plot_html(x, options) |
| 14 |
|
| 15 |
hook_plot_asciidoc(x, options) |
| 16 |
|
| 17 |
hook_plot_tex(x, options) |
| 18 |
|
| 19 |
hook_plot_md(x, options) |
| 20 |
|
| 21 |
hook_plot_rst(x, options) |
| 22 |
|
| 23 |
hook_plot_textile(x, options) |
| 24 |
} |
| 25 |
\arguments{ |
| 26 |
\item{x}{Filename for the plot (a character string).} |
| 27 |
|
| 28 |
\item{options}{A list of the current chunk options.} |
| 29 |
} |
| 30 |
\value{ |
| 31 |
A character string of code, with plot filenames wrapped. |
| 32 |
} |
| 33 |
\description{ |
| 34 |
These hook functions define how to mark up graphics output in different |
| 35 |
output formats. |
| 36 |
} |
| 37 |
\details{ |
| 38 |
Depending on the options passed over, \code{hook_plot_tex} may return the |
| 39 |
normal \samp{\\includegraphics{}} command, or \samp{\\input{}} (for tikz |
| 40 |
files), or \samp{\\animategraphics{}} (for animations); it also takes many |
| 41 |
other options into consideration to align plots and set figure sizes, etc. |
| 42 |
Similarly, \code{hook_plot_html}, \code{hook_plot_md} and |
| 43 |
\code{hook_plot_rst} return character strings which are HTML, Markdown, reST |
| 44 |
code. |
| 45 |
|
| 46 |
In most cases we do not need to call these hooks explicitly, and they were |
| 47 |
designed to be used internally. Sometimes we may not be able to record R |
| 48 |
plots using \code{grDevices::\link{recordPlot}()}, and we can make use of |
| 49 |
these hooks to insert graphics output in the output document; see |
| 50 |
\code{\link{hook_plot_custom}} for details. |
| 51 |
} |
| 52 |
\examples{ |
| 53 |
# this is what happens for a chunk like this |
| 54 |
|
| 55 |
# <<foo-bar-plot, dev='pdf', fig.align='right'>>= |
| 56 |
hook_plot_tex("foo-bar-plot.pdf", opts_chunk$merge(list(fig.align = "right"))) |
| 57 |
|
| 58 |
# <<bar, dev='tikz'>>= |
| 59 |
hook_plot_tex("bar.tikz", opts_chunk$merge(list(dev = "tikz"))) |
| 60 |
|
| 61 |
# <<foo, dev='pdf', fig.show='animate', interval=.1>>= |
| 62 |
|
| 63 |
# 5 plots are generated in this chunk |
| 64 |
hook_plot_tex("foo5.pdf", opts_chunk$merge(list(fig.show = "animate", interval = 0.1, |
| 65 |
fig.cur = 5, fig.num = 5))) |
| 66 |
} |
| 67 |
\references{ |
| 68 |
\url{https://yihui.org/knitr/hooks/} |
| 69 |
} |
| 70 |
\seealso{ |
| 71 |
\code{\link{hook_plot_custom}} |
| 72 |
} |