Improve word cloud colors
So far, you have specified only a single hexadecimal color to make your word clouds. You can easily improve the appearance of a word cloud. Instead of the #AD1DA5
in the code below, you can specify a vector of colors to make certain words stand out or to fit an existing color scheme.
wordcloud(chardonnay_freqs$term,
chardonnay_freqs$num,
max.words = 100,
colors = "#AD1DA5")
To change the colors
argument of the wordcloud()
function, you can use a vector of named colors like c("chartreuse", "cornflowerblue", "darkorange")
. The function colors()
will list all 657 named colors. You can also use this PDF as a reference.
In this exercise you will use "grey80", "darkgoldenrod1", and "tomato" as colors. This is a good starting palette to highlight terms because "tomato" stands out more than "grey80". It is a best practice to start with three colors, each with increasing vibrancy. Doing so will naturally divide the term frequency into "low", "medium", and "high" for easier viewing.
Cet exercice fait partie du cours
Text Mining with Bag-of-Words in R
Instructions
- Call the
colors()
function to list all basic colors. - Create a
wordcloud()
using the predefinedchardonnay_freqs
with the colors "grey80", "darkgoldenrod1", and "tomato". Include the top 100 terms usingmax.words
.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Print the list of colors
___
# Print the word cloud with the specified colors
___(___, ___,
___,
___)