使用python快速画图

matplotlib工具的使用

首先需要安装matplotlib

sudo pip3.5 install matplotlib

下面是源码

#!/usr/local/bin/python3.5
#-*- coding:utf-8 -*-

import matplotlib.pyplot as plt

y = [1, 0, 2, 5, 224, 732, 1129, 1223, 1241, 1274, 1396, 1670, 2063, 2516, 2991, 3521, 3972, 4174, 4076, 4030, 3531, 2916, 2301, 1740, 1187, 758, 556, 328, 199, 114, 55, 32, 23, 12, 5, 3, 0, 1]
x = [20*i for i in range(len(y))]

plt.plot(x, y, "r-", linewidth=2)
plt.ylabel('count')
plt.xlabel('score')
plt.grid(True)
plt.title("User's Score")
plt.show()

下面是画出来的图形


image.png

利用python进行简单的画图还是非常方便的

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容