19 lines
408 B
Python
19 lines
408 B
Python
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"]
|
|
|
|
genre_cnt = {}
|
|
for m in movies:
|
|
g = m["genre"]
|
|
genre_cnt[g] = genre_cnt.get(g,0)+1
|
|
|
|
x = list(genre_cnt.keys())
|
|
y = list(genre_cnt.values())
|
|
|
|
plt.bar(x,y)
|
|
plt.tight_layout()
|
|
plt.savefig("q4_1_bar.png",dpi=150)
|
|
plt.close() |