ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Text Mining with Bag-of-Words in R

Ver curso

Instrucciones del ejercicio

  • 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.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Print the list of colors
___

# Print the word cloud with the specified colors
___(___, ___,
    ___,
    ___)
Editar y ejecutar código