시작하기무료로 시작하기

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)

이 연습은 강의의 일부입니다

Text Mining with Bag-of-Words in R

강의 보기

연습 안내

  • Use cividis() to select 5 colors in an object called color_pal.
  • Review the hexadecimal colors by printing color_pal to your console.
  • Create a wordcloud() from the chardonnay_freqs term and num columns. Include the top 100 terms using max.words, and set the colors to your palette, color_pal.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Select 5 colors 
___ <- ___(___)

# Examine the palette output
___

# Create a word cloud with the selected palette
___(___)
코드 편집 및 실행