Skip to content

Update manual for use with knitr and ggplot2 #234

@tannenfreund87

Description

@tannenfreund87

I am using the console output mode of tikzDevice to include the TikZ-output directly in my tex file. Because I'm using knitr and not Sweave, the example from the manual doesn't work:

\documentclass{article}
\usepackage{tikz}
  \begin{document}
    \begin{figure}[ht]
      \centering
<<inline,echo=FALSE,results='tex'>>=

require(tikzDevice)
tikz(console=TRUE,width=5,height=5)
  x <- rnorm(100)
  plot(x)
dummy <- dev.off()
@
    \caption{caption}
    \label{fig:inline}
  \end{figure}
\end{document}

I will get all the output in a verbatim-envirionment.

Image

For the plot to show, I need to change results='tex' to results='asis'

For a ggplot2 graph I also need to use results='asis' and always end the chunk with dummy <- dev.off()

Could you update the documentation for the use with knitr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions