196_wordcloud_ex6This page illustrates the possibilities offered by the amazing wordcloud2 package developped by Chiffon Lang. It is largely inspired from the well done vignette.

First, let’s get an example dataset  and load the library:





We start with the default wordcloud, without changing any argument. Just adjust the size of the wordcloud with the size argument.

———————-196_wordcloud_ex2     196_wordcloud_ex3    196_wordcloud_ex4

It is possible to change words and background colors.

—————196_wordcloud_ex5      196_wordcloud_ex6

You can change the shape of the wordcloud. Several shapes are proposed with the package: ‘circle’ (default), ‘cardioid’, ‘diamond’ (alias of square), ‘triangle-forward’, ‘triangle’, ‘pentagon’, and ‘star’).

It is also possible to use any image you have as a mask! Just put the image in the current working directory and use it like in the code below.






Control the rotation of words with 3 arguments: minRotation, maxRotation and rotateRatio.





A nice chinese version

———–196_wordcloud_ex9 ——–196_wordcloud_ex10

The lettercloud function allows to use a letter or a word as a shape for the wordcloud

Save wordcloud2 as PDF.

Wordcloud2 is made from a html widget. It means your wordcloud will be output in a html format.

You can export it as a png image using rstudio, or using the webshot library as follow:


Not what you are looking for ? Make a new search !


Leave a Reply

2 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
2 Comment authors
DALGKevin Cazelles Recent comment authors
newest oldest most voted
Notify of

I can’t use it with my own picture by :
“wordcloud2(demoFreq, figPath = “D:/123.png”, size = 1.5, color = “skyblue”, backgroundColor=”black”)”
(picture does exist)

It shows nothing output.(no error message )

Does anyone have the same issue?

If someone can demo this process, really appreciate that.

by the way it’s a really cool function.

Kevin Cazelles

‘wordcloud2’ is very impressive. Thanks a lot for sharing it ! More generally, thanks a bunch for this website