R中的dyGraph放大并将图像另存为png

问题描述 投票:1回答:1

我想放大图形图并将图像另存为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

我想绘制放大1000多个文件的笔画。有人可以帮我吗?

r zoom dygraphs
1个回答
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")
© www.soinside.com 2019 - 2024. All rights reserved.