这是带有 r block 和图表的幻灯片的代码:
---
```{r, echo=FALSE, warning=FALSE}
dd<-data.frame(x=1:10, y=21:30)
library(ggplot2)
ggplot(dd, aes(x,y)) + geom_point(color="red", size=6) +
theme(plot.background=element_rect(fill="gray7", color="gray7"),
panel.background=element_rect(fill="gray7"),
axis.line=element_line(color="white"),
panel.grid=element_blank(),
axis.text=element_text(color="white", size=rel(1.3)),
axis.title=element_text(color="white", size=rel(1.3))
)
```
---
这是我的 YAML:
---
framework : revealjs
revealjs : {theme: night, transition: none, center: "false"}
highlighter : highlight.js
hitheme : github
widgets : [mathjax]
mode : selfcontained
url : {lib: ./libraries}
knit : slidify::knit2slides
assets:
js:
- "http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"
- "http://bartaz.github.io/sandbox.js/jquery.highlight.js"
---
这在幻灯片上给出了这个图:
显然边框在那里,因为这是reveal.js 主题的默认设置。我对大多数幻灯片上的边框都满意,但是对于某些 R block 生成的图形,我不想要它。我发现很难简单地删除它。我有一个 hacky 解决方法。我不包含该 block 的输出,然后使用一些 html 来引用刚刚命名并保存到我的 assets/fig
文件夹中的图像:
```{r, echo=FALSE, warning=FALSE, chunk_name, include=FALSE}
dd<-data.frame(x=1:10, y=21:30)
library(ggplot2)
ggplot(dd, aes(x,y)) + geom_point(color="red", size=6) +
theme(plot.background=element_rect(fill="gray7", color="gray7"),
panel.background=element_rect(fill="gray7"),
axis.line=element_line(color="white"),
panel.grid=element_blank(),
axis.text=element_text(color="white", size=rel(1.3)),
axis.title=element_text(color="white", size=rel(1.3))
)
```
<img src="assets/fig/chunk_name-1.png" style="background:none; border:none; box-shadow:none;">
---
这给出了这个输出:
这没问题,但这似乎不是正确的方法,而且我可以看到这可能不适用于所有情况。有没有更好的方法来消除 r-chunks 图形输出的边框?
编辑:对于颜色爱好者来说,#111111 是reveal.js 背景颜色,所以最好使用它。
最佳答案
Ramnath 实际上就这个问题的答案给了我一些建议:
将其放入 asset/css 中...
.noborder .reveal section img {
background:none;
border:none;
box-shadow:none;
}
然后在幻灯片标题的开头使用以下内容引用此 css:
--- ds:noborder
显然,include=T
在 R block 中。
关于html - 使用 slidify Reveal.js 删除图像边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29464295/