天天看点

使用 python Matplotlib 库绘图

matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地

下面总结步骤如下:

windows 平台上 下载.exe格式 直接安装。

下面安装Matplotlib 依赖的库

     这个档案,解压后把它拖到c:\windows\system32目录中。

5, 运行一个简单的程序例子:

使用 python Matplotlib 库绘图

import matplotlib.pyplot as plt  

plt.plot([1,2,3])  

plt.ylabel('some numbers')  

plt.show()  

发现出现了下面的错误:

raise ImportError("matplotlib requires dateutil")

ImportError: matplotlib requires dateutil

把dateutil 安装完后又出现如下错误:

raise ImportError("matplotlib requires pyparsing")

ImportError: matplotlib requires pyparsing

完成以上步骤,运行上面的例子就可以显示我们的图像,如下所示。

使用 python Matplotlib 库绘图

可以根据所画图形的需要 在下面的链接里选择相应的图形 进行修改,绘出自己所需的图像。

相关资源链接:

资源下载:

注意绘图时中文的解决方法, 在.py文件头部加上如下内容:

# -*- coding: utf-8 -*-   

from pylab import *  

mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体  

mpl.rcParams['axes.unicode_minus'] = False #解决保存图像是负号'-'显示为方块的问题 

 如果为希望能把Python脚本发布为脱离Python平台运行的可执行程序,比如单个的exe文件。

上一篇: WebService总结
下一篇: 机器学习