File tree Expand file tree Collapse file tree
PythonDemo/wordcloud/examples Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414# 读取整个文本
1515text = open (path .join (d , 'constitution.txt' )).read ()
1616
17- # Generate a word cloud image
17+ # 生成一个词云图像
1818wordcloud = WordCloud ().generate (text )
1919
20- # Display the generated image:
21- # the matplotlib way:
20+ # matplotlib的方式展示生成的词云图像
2221import matplotlib .pyplot as plt
2322plt .imshow (wordcloud , interpolation = 'bilinear' )
2423plt .axis ("off" )
2524
26- # lower max_font_size
27- wordcloud = WordCloud (max_font_size = 40 ).generate (text )
25+ #设定生成词云中的文字最大大小
26+ wordcloud = WordCloud (max_font_size = 66 ).generate (text )
2827plt .figure ()
2928plt .imshow (wordcloud , interpolation = "bilinear" )
3029plt .axis ("off" )
3130plt .show ()
3231
33- # The pil way (if you don't have matplotlib)
32+ # pil方式展示生成的词云图像(如果你没有matplotlib)
3433# image = wordcloud.to_image()
3534# image.show()
You can’t perform that action at this time.
0 commit comments