我需要从透明背景输出从R到PNG文件的ggplot2图形.基本的R图形一切都很好,但ggplot2没有透明度:
d <- rnorm(100) #generating random data
#this returns transparent png
png('tr_tst1.png',width=300,height=300,units="px",bg = "transparent")
boxplot(d)
dev.off()
df <- data.frame(y=d,x=1)
p <- ggplot(df) + stat_boxplot(aes(x = x,y=y))
p <- p + opts(
panel.background = theme_rect(fill = "transparent",colour = NA), # or theme_blank()
panel.grid.minor = theme_blank(),
panel.grid.major = theme_blank()
)
#returns white background
png('tr_tst2.png',width=300,height=300,units="px",bg = "transparent")
p
dev.off()
Run Code Online (Sandbox Code Playgroud)
有没有办法用ggplot2获得透明背景?
似乎所有需要做的就是widget: mathjax在标题页中声明.但我无法正确渲染公式.有什么遗失?谢谢.

更新:我检查了决赛index.html,发现许多"*"已成为<em>或</em>.似乎滑动混合了*LaTeX和*降价.
这是我的LaTeX片段:
\begin{align*}
&\begin{bmatrix}
\mathbf{y}\\
y_*
\end{bmatrix}
=\mathcal{N}\left(0,\begin{bmatrix}
K & K_*\\
K_*^T & K_{**}
\end{bmatrix}\right)\\
\Longrightarrow & y_*|\mathbf{y}\sim\mathcal{N}\left(K_*K^{-1}\mathbf{y},K_{**}-K_*K^{-1}K_*^T\right)\\
\Longrightarrow & \overline{y_*}=K_*K^{-1}\mathbf{y}
\end{align*}
Run Code Online (Sandbox Code Playgroud)
转换为
<li>Inference
$$\begin{align<em>}
&\begin{bmatrix}
\mathbf{y}\
y_</em>
\end{bmatrix}
=\mathcal{N}\left(0,\begin{bmatrix}
K & K<em>*\
K</em><em>^T & K_{</em><em>}
\end{bmatrix}\right)\
\Longrightarrow & y_</em>|\mathbf{y}\sim\mathcal{N}\left(K<em>*K^{-1}\mathbf{y},K</em>{*<em>}-K<em>*K^{-1}K</em></em>^T\right)\
\Longrightarrow & \overline{y<em>*}=K</em><em>K^{-1}\mathbf{y}
\end{align</em>}$$</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
更新2:我替换了_for _和*for *,以及\\for some \.现在看起来很不错:
$$\\begin{align*}
&\\begin{bmatrix}
\mathbf{y}\\\\
y_*
\\end{bmatrix} …Run Code Online (Sandbox Code Playgroud)