I've been using knitr with R base graphics and tikz output for a while now, and wanted to try out ggplot2
instead. However, this minimal example fails to produce any output with knitr 1.0.5:
\documentclass{article}
\begin{document}
<<dev = 'tikz'>>=
library(ggplot2)
d = data.frame(a = c(1, 2, 3), b = c(4, 5, 6), c = c(7, 8, 9))
ggplot(d, aes(a, b, color = c)) + geom_point()
@
\end{document}
Instead, it fails with the message Error in UseMethod("depth"): no applicable method for 'depth' applied to an object of class "NULL"
. Executing the code in R or choosing the png device will result in the expected graph. Omitting the color aesthetics or factoring c
work with tikzDevice as well, so the continuous color scale seems to be the problem.
Is there anything I am doing wrong, or is that a bug?