上传文件至 q4_3b
This commit is contained in:
20
q4_3b/zhifang_time.py
Normal file
20
q4_3b/zhifang_time.py
Normal file
@@ -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')
|
||||||
Reference in New Issue
Block a user