Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webshot() not working with wordcloud2() when figPath parameter is passed in r.

I am using webshot to save the html widget created by wordcloud2 but whenever i pass a png file to the figPath, i get a blank image. I can see the wordcloud if i open the .html file but the png created by webshot is blank. It works fine when figPath = NULL. I can't figure out why this is happening.

Here's my code :

library(wordcloud2)
library(RColorBrewer)

File <- "image.png"
library(webshot)
library(htmlwidgets)


graph <- wordcloud2(freqdf, size=clsize, color =clcolor, backgroundColor =clbgcolor,
                  figPath = clfigpath) 

saveWidget(graph,"tmp.html",selfcontained = FALSE)
webshot("tmp.html",File, delay = 20)
like image 817
angelofdeath Avatar asked Nov 09 '22 04:11

angelofdeath


1 Answers

It's my understanding that FigPath is the path to your image mask. You should try something like this:

    wordcloud2(freqdf, size=clsize, color =clcolor, backgroundColor =clbgcolor, figPath = "image.png")

Also, there's a known bug that the package creator is aware of. To get around the bug, you need to refresh the viewer or open it in the browser. See this github issue for the package creator's explanation.

Hopefully that helps.

like image 144
Kendal Avatar answered Nov 15 '22 06:11

Kendal