Matplotlib入门教程

1.安装,windows CMD命令下。。。我是Python2.7

python -m pip install -U pip setuptools
python -m pip install matplotlib

 

2、先测试画个图再BB

# -*- coding:utf-8 -*-
import matplotlib.pyplot as plt
plt.plot([1, 2, 9])
plt.ylabel('v numbers')  # y轴标签
plt.show()  # 显示

 

 

3 再画一个饼状图,来源见[参考1]

 

import matplotlib.pyplot as plt
labels = 'Python', 'Psychology', 'zchinaz', 'Economics'
sizes = 15, 20, 45, 10
colors = 'yellowgreen', 'gold', 'lightskyblue', 'lightcoral'
explode = 0, 0.1, 0, 0
plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=50)
plt.axis('equal')
plt.show()

 

 

 4 

 

 

参考

1 http://www.cnblogs.com/zhizhan/p/5615947.html

posted on 2017-08-10 17:07  零零Java  阅读(277)  评论(0编辑  收藏  举报

导航