@[TOC]词云图的绘制
词云图的绘制
功能快捷键
撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G
导入词云图的库
from wordcloud import WordCloud
导入所需数据(根据数据的路径)
with open("data.csv" ,encoding="utf-8")as file:
#1.读取文本内容
text=file.read()
#2.设置词云的背景颜色、宽高、字数
wordcloud=WordCloud(font_path="C:/Windows/Fonts/simfang.ttf",
background_color="black",width=600,
height=300,max_words=50).generate(text)
#3.生成图片
image=wordcloud.to_image()
#4.显示图片
image.show()
##如图所示图片