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.
이 연습은 강의의 일부입니다
Text Mining with Bag-of-Words in R
연습 안내
- Call the
colors()function to list all basic colors. - Create a
wordcloud()using the predefinedchardonnay_freqswith the colors "grey80", "darkgoldenrod1", and "tomato". Include the top 100 terms usingmax.words.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Print the list of colors
___
# Print the word cloud with the specified colors
___(___, ___,
___,
___)