import matplotlib.pyplot as plt
import json

rating=[]
duration=[]

with open('movie.json', 'r', encoding='utf-8') as f:
    data=json.load(f)
    # print(data)
    for i in data:
        rating.append(i["rating"])
        duration.append(i["duration"])
plt.figure(figsize=(12, 8))
plt.scatter(duration, rating,
            c='red',
            s=80,                      # 点的大小
            alpha=0.6,                 # 透明度
            edgecolors='white')         # 点的边框
plt.title('时长与评分关系散点图', fontsize=14)
plt.xlabel('时长', fontsize=12)
plt.ylabel('评分', fontsize=12)
plt.grid(True, linestyle='--', alpha=0.5)
plt.show()
       
