Python 创建词云 注意事项

1. python创建词云 只能显示英文 需要下载中文字体

simhei.ttf是中文字体 有公开资源可以下载

加载字体所在目录 font_path

2. 出现了重复词

其中参数collocations是默认值,会统计搭配词,改为False

默认collo

cations=True,会统计搭配词,改为False

def gen_WordCloud(word_num_dic):
	# 4.生成词云
	wc = WordCloud(
	    font_path='./simhei.ttf',     #字体路劲
	    background_color='white',   #背景颜色
	    #width=1000,
	    #height=600,
	    width=600,
	    height=400,
	    max_font_size=50,            #字体大小
	    min_font_size=10,
	    #mask=plt.imread('xin.jpg'),  #背景图片
	    max_words=1000,
	    collocations=False #!!!!!!!重复词
	)

整体code请参考一下reference

reference

https://www.cnblogs.com/cymwill/p/7613197.html

https://www.cnblogs.com/djdjdj123/p/12153603.html

http://blog.sina.com.cn/s/blog_af8b11b50102yi2w.html

猜你喜欢

转载自blog.csdn.net/weixin_48185819/article/details/123916519