[Tikzdevice-bugs] potential bug

24 views
Skip to first unread message

Guy Lebanon

unread,
Apr 2, 2012, 9:52:55 PM4/2/12
to tikzdev...@lists.r-forge.r-project.org
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}
_______________________________________________
Tikzdevice-bugs mailing list
Tikzdev...@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/tikzdevice-bugs

Charlie Sharpsteen

unread,
Apr 3, 2012, 11:29:00 PM4/3/12
to Guy Lebanon, tikzdev...@lists.r-forge.r-project.org
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

Reply all
Reply to author
Forward
0 new messages