完成期末练习

This commit is contained in:
2509165046
2026-07-05 16:21:26 +08:00
parent 9112fae8b4
commit 7f72c58746
15 changed files with 421 additions and 0 deletions

24
q4/q4_3a/q4_3a.py Normal file
View File

@@ -0,0 +1,24 @@
import matplotlib.pyplot as plt
import json
rating=[]
with open(r'D:\桌面\期末考试\simulated-examination\q2_1_crawler\movie.json', 'r', encoding='utf-8') as f:
data=json.load(f)
# print(data)
for i in data:
rating.append(i["rating"])
plt.figure(figsize=(12,8))
plt.hist(rating, # 数据
bins=10, # 分成几个柱子
color='#3498DB', # 颜色
edgecolor='white') # 柱子边框颜色
plt.title('评分分布', fontsize=14)
plt.xlabel('评分', fontsize=13)
plt.grid(True, linestyle='--', alpha=0.5, axis='y')
import os
save_path = os.path.join(os.path.dirname(__file__),"q4_3a_hist.png")
plt.savefig(save_path, dpi=150,format='png')
plt.show()

BIN
q4/q4_3a/q4_3a_hist.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB