形式
Plain text
投稿日時
2019-05-28 18:47
公開期間
無期限
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue May 28 17:00:04 2019
  4. @author: lndx
  5. """
  6. from matplotlib import pyplot as plt
  7. import matplotlib as mpl
  8. mpl.rcParams["font.family"]="sans-serif"
  9. mpl.rcParams["font.sans-serif"]=[u"SimHei"]
  10. import numpy
  11. import math
  12. f = open("book_list.csv","r")
  13. publish = set()
  14. pub_num={}
  15. lines = f.readlines()
  16. for line in lines:
  17. if "书名" not in line[1]:
  18. line = line.strip()
  19. line = line.split(',')
  20. line = line[-1]
  21. line = line.split(":")
  22. line = line[-1].split('/')
  23. line = line[0]
  24. if "出版" in line and len(line)>3:
  25. publish.add(line)
  26. for pub in publish:
  27. pub_num[pub]=0
  28. for line in lines:
  29. if "书名" not in line[1]:
  30. line = line.strip()
  31. line = line.split(',')
  32. line = line[-1]
  33. line = line.split(":")
  34. line = line[-1].split('/')
  35. line = line[0]
  36. if "出版" in line and len(line)>3:
  37. pub_num[line]+=1
  38. pub_num=sorted(pub_num.items(),key = lambda item:item[1],reverse=True)
  39. x=[]
  40. xname=[]
  41. for i in range(0,3):
  42. x.append(pub_num[i][1])
  43. xname.append(pub_num[i][0].strip())
  44. plt.bar(xname,x,color = "red",align = "center")
  45. plt.yticks([0,20,40,60,80,100])
  46. plt.xticks(xname)
  47. plt.title("出版社出版量统计")
  48. plt.xlabel("出版社")
  49. plt.ylabel("出版数量")
  50. plt.show()
ダウンロード 印刷用表示

このコピペの URL

JavaScript での埋め込み

iframe での埋め込み

元のテキスト