r - knitr makes multiple figures instead of adding just lines() to axes -
i have simple rnw file:
\documentclass[10pt,a4paper]{article} \usepackage[latin1]{inputenc} \begin{document} <<mychunk, echo=false, cache=false, fig.keep='all'>>= plot(rnorm(100),rnorm(100)) lines(c(-1,1),c(-1,1)) @ \end{document}
the r chunk
plot(rnorm(100),rnorm(100)) lines(c(-1,1),c(-1,1))
should give 1 figure. instead, output tex
\includegraphics[width=\maxwidth]{figure/mychunk1} \includegraphics[width=\maxwidth]{figure/mychunk2}
with 2 separate figures
,
this doesn't happen in instances of plot , lines, depending on arguments, code i've given reproduces problem. should have second figure.
you've set fig.keep="all"
, , getting expected setting! described in the online documentation, option "keep[s] plots (low-level plot changes may produce new plots)".
try instead fig.keep="high"
(the default, can leaving out fig.keep
argument) or fig.keep="last"
, depending on want.
Comments
Post a Comment