From 69b8a343d75cff1fa6f0070ad5e052289df8016c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=BA=A2=E8=BE=89?= <2509165036@student.example.com> Date: Mon, 6 Jul 2026 14:17:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=204=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 4_2 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 4_2 diff --git a/4_2 b/4_2 new file mode 100644 index 0000000..a60aa3a --- /dev/null +++ b/4_2 @@ -0,0 +1,21 @@ +import matplotlib.pyplot as plt +import json +rating=[] +duration=[] +with open('movie.json', 'r', encoding='utf-8') as f: + data=json.load(f) + # print(data) + for i in data: + rating.append(i["rating"]) + duration.append(i["duration"]) +plt.figure(figsize=(12, 8)) +plt.scatter(duration, rating, + c='red', + s=80, # 点的大小 + alpha=0.6, # 透明度 + edgecolors='white') # 点的边框 +plt.title('时长与评分关系散点图', fontsize=14) +plt.xlabel('时长', fontsize=12) +plt.ylabel('评分', fontsize=12) +plt.grid(True, linestyle='--', alpha=0.5) +plt.show()