简体   繁体   English

使用slidify manifest.js从图像中删除边框

[英]Removing border from images using slidify reveal.js

here is the code of a slide with an r chunk and a graph: 这是带有r块和图的幻灯片的代码:

---
 ```{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))
        )

```
---

this is my YAML: 这是我的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"
    ---

This gives this plot on the slide: 这在幻灯片上给出了该图:

在此处输入图片说明

Obviously the border is there because this is the default for the reveal.js theme. 显然有边框,因为这是Reveal.js主题的默认设置。 I'm ok with the border on most slides, however for graphs being produced by some R chunks, I don't want it. 我可以接受大多数幻灯片的边框,但是对于某些R块生成的图形,我不想要它。 I'm finding it hard to remove this simply. 我发现很难简单地删除它。 I have a hacky work-around. 我有一个棘手的解决方法。 I don't include the output of the chunk and then I use some html to refer to the image that's just been named and saved to my assets/fig folder: 我不包含该块的输出,然后使用一些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;">

---

This gives this output: 这给出了以下输出:

在此处输入图片说明

This is ok, but it doesn't seem the right way to do this and I can see how this might not work in all situations. 没关系,但这似乎不是正确的方法,我可以看到这可能在所有情况下都不起作用。 Is there a better way to get rid of borders for the graphical output of r-chunks ? 是否有更好的方法来消除r块的图形输出的边界?

edit: For the color aficionados, #111111 is the reveal.js background color, so would have been better to use that. 编辑:对于颜色爱好者,#111111是Reveal.js背景颜色,因此最好使用该颜色。

Ramnath actually gave me some advice as to the answer to this question: 实际上,拉姆纳特就这个问题的答案给了我一些建议:

into assets/css put this... 放入资产/ css中...

.noborder .reveal section img {
  background:none; 
  border:none; 
  box-shadow:none;
  }

Then refer to this css using the following at the beginning of your slide header: 然后在幻灯片标题的开头使用以下内容引用此CSS:

--- ds:noborder

and obviously, include=T in the R chunk. 并且显然,在R块中include=T

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM