본문 바로가기

Python_Intermediate/WordCloud

WordCloud Font Single Hex Color

반응형

Code>

from wordcloud import WordCloud
from matplotlib import pyplot

def make_colors(word, font_size, position, orientation, random_state, **kwargs):
color = "Hex Color Code"
return color

text = ''
with open("파일경로", encoding="utf-8") as f:
text = f.read()

wc = WordCloud(width=1200, height=800, scale=2.0, max_font_size=150,
background_color="#ffffff")
gen = wc.generate(text)

recolor = gen.recolor(color_func=make_colors, random_state=True)

pyplot.figure()
pyplot.imshow(recolor, interpolation='bilinear')
wc.to_file("출력파일명")
pyplot.close()

정리>

글자 색상을 단일 색깔로 지정한다.

color = hex Color

hex Color는 https://www.colorhexa.com를 참조하면 좋다.


예제 출력물>


반응형

'Python_Intermediate > WordCloud' 카테고리의 다른 글

WordCloud Font HSL Color  (0) 2019.04.20
WordCloud Font RGB Color  (0) 2019.04.20
WordCloud Option Background image  (0) 2019.04.20
WordCloud Option Forbidden word  (0) 2019.04.20
WordCloud Basic  (0) 2019.04.20