17 lines
425 B
Python
17 lines
425 B
Python
# q4/q4_3b/q4_3b.py
|
|
import json
|
|
import matplotlib.pyplot as plt
|
|
|
|
with open("../q2_1_crawler/movies.json", "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
movies = data["movies"]
|
|
durations = [m["duration"] for m in movies]
|
|
|
|
# 直方图 bins=5 绿色
|
|
plt.hist(durations, bins=5, color="green")
|
|
plt.title("时长分布")
|
|
plt.xlabel("时长(分钟)")
|
|
plt.tight_layout()
|
|
|
|
plt.savefig("q4_3b_hist.png", dpi=150)
|
|
plt.show() |