2016-01-18 52 views
4

我已經在R中創建了一個陰謀圖表,然後通過htmlwidget保存圖表,這樣可以調用plotify。我玩widthheight,在layout參數和index.Rmd都適合滑動幻燈片的情節,但最終結果總是削減圖表的底部時,一些文本添加在一起。調整sliderify中陰謀圖表的大小

我該如何真正調整slipify中的圖表大小?

R中的腳本代碼index.Rmd

## first slide 
date <- seq(from = as.POSIXct("2015/4/1"), 
      to = as.POSIXct("2015/10/1"), 
      by = "month") 

as.Date(date, "%Y/%m/%d") 

set.seed(2016) 
tot.prem <- runif(n = 7, min = 0, max = 1200) 
pol.frce <- runif(n = 7, min = 0, max = 6000) 
tot.data <- cbind(date, tot.prem, pol.frce) 
tot.data <- data.frame(Date = as.POSIXct(date, format = "%Y/%m/%d"), 
        WP = tot.prem, 
        PIF = pol.frce) 

m = list(
    l = 50, 
    r = 50, 
    b = 100, 
    t = 100, 
    pad = 4 
) 

p1 <- tot.data %>% 
    subplot(plot_ly(x = date, y = tot.prem, type = "bar"), 
      plot_ly(x = date, y = pol.frce, type = "bar"), margin = 0.05) %>% 
    layout(showlegend = FALSE, 
     title = "Written Premium and PIF", 
     yaxis = list(title = "WP (in Millions)", showgrid = FALSE), 
     xaxis = list(title = "Date"), 
     yaxis2 = list(title = "Policy in Force", showgrid = FALSE), 
     xaxis2 = list(title = "Date"), 
     autosize = F, width = 600, height = 400, margin = m 
     ) 
p1 
# saveWidget(dplot, 'plotlyex1.html') 
htmlwidgets::saveWidget(as.widget(p1), "wp.html") 

摘錄

## Program Summary 

- Point 1: blah blah blah 
- Point 2: blah blah blah 
- Point 3: blah blah blah 

```{r wp, echo=FALSE, warning=FALSE, cache=FALSE, results='asis'} 
cat('<iframe src="./assets/widgets/wp.html" width=100% height=10% allowtransparency="true"> </iframe>') 
``` 

--- 

幻燈片slidify

回答

0

我找到了解決的文字問題,但不是你大小查詢。如果您在圖表下放置一些文本,則x軸文本將正確顯示。如果你不想要的文本,空白字符也適用,如:

```{r wp, echo=FALSE, warning=FALSE, cache=FALSE, results='asis'} 
cat('<iframe src="./assets/widgets/wp.html" width=100% height=10% allowtransparency="true"> </iframe>') 
``` 
&#032; 

你的代碼幫助我在Slidify我的第一Plotly顯示,所以向你表示感謝。