diff --git a/生成词云图.py b/生成词云图.py new file mode 100644 index 0000000..4861ef8 --- /dev/null +++ b/生成词云图.py @@ -0,0 +1,11 @@ +def create_word_cloud(keyword_counts): + """ + 生成词云图。 + :param keyword_counts: 关键词及其出现次数的字典 + """ + wc = WordCloud(font_path='simhei.ttf', background_color='white', width=800, height=600) + wc.generate_from_frequencies(keyword_counts) + plt.imshow(wc, interpolation='bilinear') + plt.axis("off") + plt.title("Top Danmakus Related to AI Technology in 2024 Paris Olympics") + plt.show() \ No newline at end of file