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:


196_wordcloud_ex1

 

 

 

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.


196_wordcloud_ex7

 

 

 

 

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


196_wordcloud_ex8

 

 

 

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 !

[mediatagger]


1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Kevin Cazelles Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Kevin Cazelles
Guest

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