Lchiffon / wordcloud2

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

How to display wordcloud2 in a jupyter notebook with IRkernel #10

Open hxhc opened 7 years ago

hxhc commented 7 years ago

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)

denotepython commented 7 years ago

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

MitzTD commented 2 years ago

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)