I have created a Sankey diagram using the riverplot
package, with the help of the website from google (https://developers.google.com/chart/interactive/docs/gallery/sankey) and the community here.
I am very happy with the graph now and would like to save it as a .svg, however I can not find the code in R to save it.
Does anyone know how to do this?
Thank you very much for your help.
Here is my code:
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
))
)
I have also tried to use online software to convert the html file created (like here: Can I export part of an HTML page to an SVG image?), but I think due to the interactivity this is not possible