From 51c2b15ad0ac62452f01074f131c72d40f789c80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E7=8E=B2=E7=8E=B2?= <2509165008@student.example.com> Date: Sun, 5 Jul 2026 14:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20q4=5F3a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4_3a/zhifang_rating.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 q4_3a/zhifang_rating.py diff --git a/q4_3a/zhifang_rating.py b/q4_3a/zhifang_rating.py new file mode 100644 index 0000000..ffde26d --- /dev/null +++ b/q4_3a/zhifang_rating.py @@ -0,0 +1,21 @@ +import matplotlib.pyplot as plt +import json + +rating=[] + +with open('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') +plt.show() +plt.savefig("q4_3a_hist.png",dpi=150,format='png') \ No newline at end of file