【发布时间】:2018-10-25 03:21:23
【问题描述】:
在谷歌网站 (https://developers.google.com/chart/interactive/docs/gallery/sankey) 和社区的帮助下,我使用 riverplot 包创建了一个桑基图。
我现在对图表非常满意,并希望将其保存为 .svg,但是我无法在 R 中找到代码来保存它。
有谁知道怎么做?
非常感谢您的帮助。
这是我的代码:
df <- my data
colors_node <- c('green','blue','red','yellow','brown','orange','darkviolet',
'grey','navy','aquamarine','darkgreen','firebrick')
colors_node_array <- paste0("[", paste0("'", colors_node,"'", collapse = ','), "]")
opts <- paste0("{
iterations: 0,
link: { color: { stroke: 'black', strokeWidth: 1 } },
node: { colors: ", colors_node_array ,",
label: { fontName: 'Arial',
fontSize: 8,
color: '#871b47',
bold: true,
italic: true }}
}" )
plot(
gvisSankey(df, from="origin",
to="visit", weight="weight",
options=list(
height=400, width = 300,
sankey=opts
))
)
我也尝试使用在线软件来转换创建的 html 文件(比如这里:Can I export part of an HTML page to an SVG image?),但我认为由于交互性,这是不可能的
【问题讨论】: