放大R中的dyGraphs并将图像保存为png

时间:2018-06-12 13:09:41

标签: r zoom dygraphs

我想放大dygraphs并将图像保存为png。我使用dygraph库绘制图形并将其保存为png,但它没有放大版本。

library("webshot")
library("htmlwidgets")
lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
  dyHighlight(highlightCircleSize = 5, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE)

saveWidget(ab, "/path/", selfcontained = TRUE, libdir = NULL)

basePng <- paste("images",paste(file,".png"), sep='/')
webshot::webshot("/path/",file=basePng)

enter image description here

但我想要下面的情节(放大):

enter image description here

我想在dygraph中绘制超过1000个文件的缩放图。有谁可以帮我这个?

1 个答案:

答案 0 :(得分:1)

我希望这个答案可以帮助任何人,

我使用dyRangeSelector()“缩放”图形,然后webshot进行保存。

library(webshot)
library(htmlwidgets)
library(dygraphs)

# webshot::install_phantomjs()

lungDeaths <- cbind(ldeaths, mdeaths, fdeaths)
dygraph(lungDeaths, main = "Deaths from Lung Disease (UK)") %>%
        dyRangeSelector( dateWindow = c("1974-03-1","1974-06-10")) %>%
        dyHighlight(highlightCircleSize = 5, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE)

saveWidget(ab,file ="ab.html", selfcontained = TRUE, libdir = NULL)

webshot(url = "ab.html",file="ab.png")