draw_util.py 479 B

1234567891011121314151617181920
  1. #!/usr/bin/python
  2. # -*- coding: UTF-8 -*-
  3. import matplotlib.pyplot as plt
  4. #绘制散点图
  5. def drawScatter(heights,weights):
  6. #创建散点图
  7. #第一个参数为点的横坐标
  8. #第二个参数为点的纵坐标
  9. plt.scatter(heights,weights)
  10. plt.xlabel('Heights')
  11. plt.ylabel('Weight')
  12. plt.title('Heights & Weight of Students')
  13. plt.show()
  14. if __name__ == '__main__':
  15. heights = [1.5, 1.7]
  16. weights = [43, 61]
  17. drawScatter(heights,weights)