This commit is contained in:
2509165008
2026-06-25 16:01:33 +08:00
parent 10f33afbc4
commit a581258d91
27 changed files with 421 additions and 167 deletions

View File

@@ -1 +0,0 @@
# 此目录用于存放学生提交的文件,请勿删除

33
q4/q4_1/q4_1.py Normal file
View File

@@ -0,0 +1,33 @@
import matplotlib.pyplot as plt
import json
with open('movie.json', 'r', encoding='utf-8') as f:
data=json.load(f)
# print(data)
genre_shu={}
for g in data:
ge=g["genre"]
if ge in genre_shu:
genre_shu[ge]+=1
else:
genre_shu[ge]=1
# print("各类型的电影数量",genre_shu)
genre_lei=list(genre_shu.keys())
genre_liang=list(genre_shu.values())
print(genre_liang)
plt.figure(figsize=(14, 12))
plt.bar(genre_lei, genre_liang, # 类别, 数值
width=0.6) # 柱子宽度0~1之间
# 标题和标签
plt.title('类型电影数量分布', fontsize=14)
plt.xlabel('类型名称', fontsize=12)
plt.ylabel('电影数量', fontsize=12)
plt.show()

BIN
q4/q4_1/q4_1_bar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB