diff --git a/picture.py b/picture.py new file mode 100644 index 0000000..d787ebd --- /dev/null +++ b/picture.py @@ -0,0 +1,16 @@ +import matplotlib.pyplot as plt +from wordcloud import WordCloud +import jieba + +# 读取弹幕数据 +df = pd.read_excel('danmakus.xlsx') + +# 生成词云 +text = ' '.join(jieba.cut(' '.join(df['danmaku']))) +wordcloud = WordCloud(font_path='msyh.ttc', width=800, height=400).generate(text) + +# 显示词云 +plt.figure(figsize=(10, 5)) +plt.imshow(wordcloud, interpolation='bilinear') +plt.axis('off') +plt.show()