Use prebuilt color palettes
In celebration of your text mining skills, you may have had too many glasses of chardonnay while listening to Marvin Gaye. So if you find yourself unable to pick colors on your own, you can use the viridisLite package. viridisLite color schemes are perceptually-uniform, both in regular form and when converted to black-and-white. The colors are also designed to be perceived by readers with color blindness.
There are multiple color palettes, each with a convenience function. Simply specify n to select the number of colors needed.
magma(n = 3)
plasma(n = 5)
inferno(n = 6)
Each function returns a vector of hexadecimal colors based on n.
Here's an example used with wordcloud:
color_pal <- cividis(n = 7)
wordcloud(chardonnay_freqs$term, chardonnay_freqs$num, max.words = 100, colors = color_pal)
Diese Übung ist Teil des Kurses
Text Mining with Bag-of-Words in R
Anleitung zur Übung
- Use
cividis()to select5colors in an object calledcolor_pal. - Review the hexadecimal colors by printing
color_palto your console. - Create a
wordcloud()from thechardonnay_freqstermandnumcolumns. Include the top 100 terms usingmax.words, and set thecolorsto your palette,color_pal.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Select 5 colors
___ <- ___(___)
# Examine the palette output
___
# Create a word cloud with the selected palette
___(___)