From bc791f283cde8d1038ff95c51e32ca11175e0b07 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:49:30 +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=5F3b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- q4_3b/zhifang_time.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 q4_3b/zhifang_time.py diff --git a/q4_3b/zhifang_time.py b/q4_3b/zhifang_time.py new file mode 100644 index 0000000..3ff0e69 --- /dev/null +++ b/q4_3b/zhifang_time.py @@ -0,0 +1,20 @@ +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=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_3b_hist.png",dpi=150,format='png') \ No newline at end of file