From fc56f89ac214869a285981c939eb8b18a5e7419f Mon Sep 17 00:00:00 2001 From: pg78ac9nr <2401677463@qq.com> Date: Wed, 18 Sep 2024 20:45:40 +0800 Subject: [PATCH] ADD file via upload --- 生成词云图.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 生成词云图.py 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