2015-04-06 50 views
1

從圖像中刪除邊框這裏是被R塊和圖表幻燈片的代碼:使用slidify reveal.js

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

這給了這個陰謀在幻燈片上:

enter image description here

明顯的邊界是有,因爲這是默認爲reveal.js主題。我對大多數幻燈片的邊框都沒問題,但是對於某些R塊產生的圖形,我不需要它。我發現很難簡單地刪除它。我有一個hacky解決方法。我不包括組塊的輸出,然後我用一些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;"> 

--- 

這給出了這樣的輸出:

enter image description here

這是好的,但它似乎並沒有正確的方式來做到這一點,我可以看到這可能不適用於所有情況。有沒有更好的方法來擺脫r-chunk的圖形輸出的邊界?

編輯:對於顏色愛好者來說,#111111是reveal.js背景顏色,所以本來會更好地使用它。

回答

2

Ramnath居然給了我一些建議作爲對這個問題的答案:

置入資產/ CSS把這個...

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

然後用指這個CSS以下之初您的幻燈片標題:

--- ds:noborder 

顯然,include=T在R塊中。

相關問題