christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 270 forks source link

Save output image as SVG format #298

Closed anbai106 closed 1 year ago

anbai106 commented 1 year ago

Hi,

I don't know if this is the right question, but can we save the output image as SVG format? Rstudio or R default svg function does not work.

Thanks

cjyetman commented 1 year ago

not directly, but there are a number of possible ways to save the output of a htmlwidget as an SVG, e.g... https://stackoverflow.com/a/57751023/4389763 https://stackoverflow.com/a/64673967/4389763 https://github.com/cjyetman/network.r2d3/blob/main/R/save_as_svg.R

anbai106 commented 1 year ago

Thanks so much for your quick reply!

I have another question. For the Sankey plot, how can I make the nodes with the same color (defined by NodeGroup parameter) in the same column?

Say: shallow blue is a group of genes, dark orange is a group of drugs and shallow orange is a group of diseases.

Screenshot from 2023-01-24 10-19-41

I can only drag these nodes vertically but not horizontally after I generate the image.

Great tool!

Thanks

cjyetman commented 1 year ago

That is also something that {networkD3} was not designed to do. The primary functionality of {networkD3} is automatically determining and plotting an "ideal" layout of networks, for quick and easy interactive exploration. If you want a lot of control over where/how nodes are positioned etc. (e.g. for publication and/or static images), {networkD3} is probably not the best tool for that.