R googleVis 到 png 文件
R googleVis to png file
我有以下代码可以正常工作。我想知道是否可以将其导出为 png 文件。任何人都知道一个简单的方法来做到这一点。我刚刚开始接触 R 世界,所以是个菜鸟。
这是我的代码
library(RODBC)
library(googleVis)
con <- odbcConnect("Live", uid="Rxyzuser", pwd="xxxxx")
attendees <- sqlQuery(con, "exec rpt_r_vis")
regCal <- gvisCalendar(attendees,
datevar="Reg_add_date",
numvar="Counts",
options=list(
title = "Registrations per Day Heatmap",
height = 400, width=1000,
calendar="{yearLabel: { fontName: 'Times-Roman',
fontSize: 32, color: '#1A8663', bold: true}, cellSize: 15,
cellColor: { stroke: 'red', strokeOpacity: 0.2 },
focusedCellColor: {stroke: 'red'}}")
)
plot(regCal)
odbcCloseAll()
你试过了吗:
png("sample.png",width = 480, height = 480, units = "px")
plot(regCal)
dev.off()
最佳,
罗伯特
我正在考虑将使用 googleVis
生成的 html 文件保存为 png 格式,然后在这里偶然发现了这个线程。我能够使用 webshot2::webshot()
.
解决我的问题
即您使用 googleVis
创建一个 html 文件,然后使用 webshot2::webshot()
生成一个 png。
dat <- data.frame(From=c(rep("A",3), rep("B", 3)),
To=c(rep(c("X", "Y", "Z"),2)),
Weight=c(5,7,6,2,9,4))
sk1 <- googleVis::gvisSankey(dat, from="From", to="To", weight="Weight")
cat(sk1$html$chart, file = "Sankey.html")
webshot2::webshot(url = "Sankey.html",
file = "Sankey.png",
vheight = 400,
vwidth = 430,
zoom = 5)
我有以下代码可以正常工作。我想知道是否可以将其导出为 png 文件。任何人都知道一个简单的方法来做到这一点。我刚刚开始接触 R 世界,所以是个菜鸟。
这是我的代码
library(RODBC)
library(googleVis)
con <- odbcConnect("Live", uid="Rxyzuser", pwd="xxxxx")
attendees <- sqlQuery(con, "exec rpt_r_vis")
regCal <- gvisCalendar(attendees,
datevar="Reg_add_date",
numvar="Counts",
options=list(
title = "Registrations per Day Heatmap",
height = 400, width=1000,
calendar="{yearLabel: { fontName: 'Times-Roman',
fontSize: 32, color: '#1A8663', bold: true}, cellSize: 15,
cellColor: { stroke: 'red', strokeOpacity: 0.2 },
focusedCellColor: {stroke: 'red'}}")
)
plot(regCal)
odbcCloseAll()
你试过了吗:
png("sample.png",width = 480, height = 480, units = "px")
plot(regCal)
dev.off()
最佳,
罗伯特
我正在考虑将使用 googleVis
生成的 html 文件保存为 png 格式,然后在这里偶然发现了这个线程。我能够使用 webshot2::webshot()
.
即您使用 googleVis
创建一个 html 文件,然后使用 webshot2::webshot()
生成一个 png。
dat <- data.frame(From=c(rep("A",3), rep("B", 3)),
To=c(rep(c("X", "Y", "Z"),2)),
Weight=c(5,7,6,2,9,4))
sk1 <- googleVis::gvisSankey(dat, from="From", to="To", weight="Weight")
cat(sk1$html$chart, file = "Sankey.html")
webshot2::webshot(url = "Sankey.html",
file = "Sankey.png",
vheight = 400,
vwidth = 430,
zoom = 5)