平安校园
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 line
931 B

  1. import sys
  2. import matplotlib.pyplot as plt
  3. import matplotlib.font_manager as fm
  4. font_path = "C:\\Windows\\Fonts\\msyh.ttc" # 这里是微软雅黑的路径,根据需要修改
  5. prop = fm.FontProperties(fname=font_path)
  6. plt.rcParams['font.family'] = prop.get_name()
  7. def main():
  8. # 第一个参数是脚本路径,忽略它
  9. script_path = sys.argv[0]
  10. # 获取传递的参数
  11. filePath = sys.argv[1]
  12. title = sys.argv[2]
  13. labale = sys.argv[3].split(",") # 接收三个数组参数
  14. values=[int(x) for x in sys.argv[4].split(",")]
  15. # 打印参数
  16. plt.pie( values, labels=labale, colors=['#FF6384','#36A2EB','#4BC0C0','#FFCE56','#FF9F40','#FFB3E6','#C2C2F0','#FF5733','#DAF7A6','#FFC300' ],autopct='%1.1f%%')
  17. # 确保饼图是圆形的
  18. plt.axis('equal')
  19. # 添加标题
  20. # 显示图表
  21. plt.title(title)
  22. # plt.show()
  23. plt.savefig(filePath)
  24. if __name__ == "__main__":
  25. main()