相关疑难解决方法(0)

如何使用ggplot2在R中制作具有透明背景的图形?

我需要从透明背景输出从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获得透明背景?

graphics transparency r ggplot2

113
推荐指数
3
解决办法
8万
查看次数

如何在Slidify中使用MathJax?

似乎所有需要做的就是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>}
&amp;\begin{bmatrix}
\mathbf{y}\
y_</em>
\end{bmatrix}
=\mathcal{N}\left(0,\begin{bmatrix}
K &amp; K<em>*\
K</em><em>^T &amp; K_{</em><em>}
\end{bmatrix}\right)\
\Longrightarrow &amp; 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 &amp; \overline{y<em>*}=K</em><em>K^{-1}\mathbf{y}
\end{align</em>}$$</li>
</ul>
Run Code Online (Sandbox Code Playgroud)

更新2:我替换了&#95;for _&#42;for *,以及\\for some \.现在看起来很不错:

$$\\begin{align&#42;}
&\\begin{bmatrix}
\mathbf{y}\\\\
y&#95;&#42;
\\end{bmatrix} …
Run Code Online (Sandbox Code Playgroud)

markdown slidify

6
推荐指数
0
解决办法
1362
查看次数

标签 统计

ggplot2 ×1

graphics ×1

markdown ×1

r ×1

slidify ×1

transparency ×1