ComeçarComece de graça

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.

Este exercício faz parte do curso

Text Mining with Bag-of-Words in R

Ver curso

Instruções do exercício

  • Call thecolors() function to list all basic colors.
  • Create a wordcloud() using the predefined chardonnay_freqs with the colors "grey80", "darkgoldenrod1", and "tomato". Include the top 100 terms using max.words.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Print the list of colors
___

# Print the word cloud with the specified colors
___(___, ___,
    ___,
    ___)
Editar e executar o código