期末
This commit is contained in:
@@ -1,6 +1,16 @@
|
||||
import matplotlib.pyplot as plt
|
||||
import json
|
||||
with open ("movies.json","r",encoding='utf-8') as f:
|
||||
print(f)
|
||||
genre_count=()
|
||||
plt.bar
|
||||
movies= json.load(open('movies.json',encoding='utf-8'))
|
||||
genres= {}
|
||||
for m in movies:
|
||||
g=m['genre']
|
||||
if g in genres:
|
||||
genres['g'] = genres['g']+1
|
||||
else:
|
||||
genres['g']=1
|
||||
plt.figure(figsize=(8,5))
|
||||
plt.bar(genres.keys(),genres.values())
|
||||
plt.title("类型电影数量分布")
|
||||
plt.xlabel("类型")
|
||||
plt.ylabel("数量")
|
||||
plt.savefig('q4_1_bar.png', dpi=150)
|
||||
|
||||
Reference in New Issue
Block a user