How to display wordcloud2 in a jupyter notebook with IRkernel
WordCloud2 is a fancy job, but I wonder if it could be displayed right in a jupyter notebook. I tried a simple way but failed.
library(wordcloud2)
wordcloud2(demoFreq)
HTML widgets cannot be represented in plain text (need html)
good question,my jupyter has another problem with wordcloud2 "Warning message in readChar(htmlfile, file.info(htmlfile)$size): "在non-UTF-8 MBCS语言环境里只能读取字节"" a warning but no output. at the same time, give a star to my teacher lang! ——liuqian
I had success with the following code.
devtools::install_github("lchiffon/wordcloud2") install.packages("webshot")
library(wordcloud2) library(htmlwidgets) library(webshot) webshot::install_phantomjs() library(IRdisplay)
my_graph <- wordcloud2(demoFreq) my_html = "tmp.html" saveWidget(my_graph, my_html, selfcontained = FALSE) my_png = "wordcloud2.png" webshot(my_html, my_png, delay = 5) display_png(file = my_png)