ipython notebook安装见http://blog.csdn.net/u012332571/article/details/38563897,完成后。
在ipython notebook中运行一个简单的程序例子:
- import matplotlib.pyplot as plt
- plt.plot([1,2,3])
- plt.ylabel('point')
- plt.show()
安装过程遇到的错误
发现出现了下面的错误:
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
这个需要dateutil,你可以到这里下载安装。
把dateutil 安装完后又出现如下错误:
raise ImportError("matplotlib requires pyparsing")
ImportError: matplotlib requires pyparsing
需要 pyparsing 到这里下载安装。
ImportError: No module named six
将\python\python2.7\Lib\site-packages\scipy\lib中的six.py six.pyc six.pyo三个文件拷贝到 \python\python2.7\Lib\site-packages目录下即可。
完成以上步骤,运行上面的例子就可以显示我们的图像,如下所示。
在程序安装过程中如果遇到需要安装的一些依赖包,你可以到这里查找(点我),确实是个好资源。
可以根据所画图形的需要 在下面的链接里选择相应的图形 进行修改,绘出自己所需的图像。
example: http://matplotlib.org/examples/index.html, gallery:http://matplotlib.org/gallery.html
中文乱码解决方法
注意绘图时中文的解决方法, 在.py文件头部加上如下内容:
- # -*- coding: utf-8 -*-
- from pylab import *
- mpl.rcParams['font.sans-serif'] = ['SimHei'] #指定默认字体
-
mpl.rcParams['axes.unicode_minus'] = False #解决保存图像是负号'-'显示为方块的问题
我把安装 python matplotlib所需的软件放到百度网盘了,可以到这里这下。
绘图脚本.py转为 .exe
如果为希望能把Python脚本发布为脱离Python平台运行的可执行程序,比如单个的exe文件。
可以参考这篇博文:http://blog.csdn.net/daniel_ustc/article/details/15501385