From 56bb3e5eba8354fd35f75e7b394e5b7cae9b31b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E4=BC=9F=E6=B3=B0?= <2509165006@student.example.com> Date: Mon, 6 Jul 2026 14:23:40 +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/q4=5F2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4/q4_2/q4_2.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 q4/q4_2/q4_2.py diff --git a/q4/q4_2/q4_2.py b/q4/q4_2/q4_2.py new file mode 100644 index 0000000..fb70cf0 --- /dev/null +++ b/q4/q4_2/q4_2.py @@ -0,0 +1,18 @@ +import json +import matplotlib.pyplot as plt + +movies = json.load(open('movies.json', encoding='utf-8'))['movies'] +# print(movies) + +ratings = [] +durations = [] +for m in movies: + ratings.append(m['rating']) + durations.append(m['duration']) + +plt.figure(figsize=(8,5)) +plt.scatter(durations,ratings,colors='red',alpha=0.6) +plt.title('时长与评分关系散点图') +plt.xlabel('duration') +plt.ylabel('rating') +plt.savefig('q4_2_scatter.png', dpi=150) \ No newline at end of file