From 8e96ef814b70a115d858072e6ba3318c48b4f977 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:18:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=204=5F4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 4_4 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 4_4 diff --git a/4_4 b/4_4 new file mode 100644 index 0000000..46a7cf0 --- /dev/null +++ b/4_4 @@ -0,0 +1,17 @@ +import matplotlib.pyplot as plt +import json +duration=[] +with open('movie.json', 'r', encoding='utf-8') as f: + data=json.load(f) + # print(data) + for i in data: + duration.append(i["duration"]) +plt.figure(figsize=(12,8)) +plt.hist( duration, # 数据 + bins=3, # 分成几个柱子 + color='#3498DB', # 颜色 + edgecolor='white') # 柱子边框颜色 +plt.title('时长分布', fontsize=14) +plt.xlabel('时长(分钟)', fontsize=13) +plt.grid(True, linestyle='--', alpha=0.5, axis='y') +plt.show() \ No newline at end of file