[Tikzdevice-bugs] potential bug

Charlie Sharpsteen chuck at sharpsteen.net
Wed Apr 4 05:29:00 CEST 2012


On Monday, April 2, 2012 6:52:55 PM UTC-7, Guy Lebanon wrote:
>
> a potential bug when I use tikzDevice and knitr (Yihui mentioned I should
> email it to this address).
>
> Guy
>
> ----------
>
> The following code compiles nicely but the "$\\theta$" inside ggplot2's
> facets do not propagate properly. I would like to have the greek symbol in
> the facets. In other words, I can use "$\\theta$" as arguments to xlab or
> ylab, but not for facets.
>
> \documentclass{article}
> \begin{document}
>
> <<sasd,dev='tikz'>>=
> x=c(0,1)
>
> D=stack(list("$\\theta=0.3$"=dbinom(x,1,0.3),'$\\theta=0.5$'=dbinom(x,1,0.5),'$\\theta=0.9$'=dbinom(x,1,0.9)))
> names(D)=c("mass","theta")
> D$x=x
> qplot(x, mass, data=D, geom='bar', stat='identity', facets=.~theta,
>             xlab="$x$",ylab="$p_X(x)$",main='Bernoulli Distribution Mass
> Functions')
> @
>
> \end{document}
>

Hi Guy,

I cannot reproduce this bug in the absence of Knitr. Given a slight
modification of your example:

require(ggplot2)
require(tikzDevice)

x=c(0,1)
D=stack(list("$\\theta=0.3$"=dbinom(x,1,0.3),
  '$\\theta=0.5$'=dbinom(x,1,0.5),
  '$\\theta=0.9$'=dbinom(x,1,0.9)))
names(D)=c("mass","theta")
D$x=x
p <- qplot(x, mass, data=D, geom='bar', stat='identity', facets=.~theta,
  xlab="$x$",ylab="$p_X(x)$",
  main='Bernoulli Distribution Mass Functions')

tikz('test.tex', standAlone = TRUE)
print(p)
dev.off()


The standalone file `test.tex` compiles fine and contains the expected
output.

-Charlie


More information about the Tikzdevice-bugs mailing list