You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
575 B

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
# 设置默认字体以支持中文
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
# 读取 Excel 文件
df = pd.read_excel('danmu_statistics.xlsx', sheet_name='AI 技术关键词')
# 数据在名为 '关键词' 和 '出现次数' 的列中
categories = df['关键词']
values = df['出现次数']
# 绘制饼状图
plt.figure(figsize=(8, 6))
plt.pie(values, labels=categories, autopct='%1.1f%%', startangle=140)
plt.title('AI 技术各关键词占比')
plt.show()