Lchiffon / wordcloud2

R interface to wordcloud for data visualization.
397 stars 113 forks source link

Locally exporting the wordclouds to png or svg format #8

Closed DominiqueMakowski closed 7 years ago

DominiqueMakowski commented 7 years ago

Thank for your impressive work,

Do you know if there is any possibility to nicely save the cloud in png or svg format? Being able to change the resolution and such would be really nice :)

Cheers

Lchiffon commented 7 years ago

Currently, wordcloud2 can be exported by Rstudio:

Use the Export -> Save As Image menu within the RStudio Viewer (this will let the user export a PNG of whatever size they need).

I'm still looking for a good method for exporting from R codes.

Lchiffon commented 7 years ago

I'll write a new function to solve exporting. You can try it like this:

install.packages("webshot")
webshot::install_phantomjs()
library(wordcloud2)
hw = wordcloud2(demoFreq,size = 3)
saveWidget(hw,"1.html",selfcontained = F)
webshot::webshot("1.html","1.png",vwidth = 1992, vheight = 1744, delay =10)
badbye commented 7 years ago

Save canvas to SVG: http://jsfiddle.net/pfp9y5xp/, hope it can be helpful.