使用python的包matplotlib来画图

2025-05-23 20:21:34

1、python安装(之前写过一篇关于python的安装,这里不重复介绍) (1) 如何下载?百度---> Python官网 (2)版本:python-3.4.3.amd64 exe文件直接点哦 (3)目录:D:\Python34 为python配置了环境变量:D:\Python34\Scripts;D:\Python34 (4) 命令行输入:python 有反应表示成功说明:matplotlib还没有匹配python3.5的版本,我的电脑为64位

2、软件包下载:因为涉及到众多包的下载,以及其中的版本和电脑位数问题特介绍如下(注意加粗的字体): 猾诮沓靥(1) numpy numpy-1.10.1+mkl-cp34-none-win_锾攒揉敫amd64.whl (2)matplotlib matplotlib-1.4.3.win-amd64-py3.4b/matplotlib-1.4.3/windows/(3) 依赖包:pyparsing、dateutil、scipy声明:以上软件地址可自行百度搜索附注:图一为matplotlib 、图二为numpy 下载界面的选择

使用python的包matplotlib来画图
使用python的包matplotlib来画图

3、软件包numpy的安装:1 命令行输入【完整的路径=numpy 在你电脑的绝对路径】 pip install 完整的路径\numpy-1.10.1+mkl-cp34-none-win_amd64.2 验证:python编辑下 python>> from numpy import *

使用python的包matplotlib来画图

4、安装matplotlib: matplotlib-1.4.3.win-amd64-py3.4 因为下载的是exe文件,点击一路执行即可

使用python的包matplotlib来画图
使用python的包matplotlib来画图

5、依赖包的安装:在命令行里逐行输入如下命令:软件包的绝对路径 1 pip install 绝对路径\pyparsing-2.0.3-py3-none-any.whl 2 pip install 绝对路径\python_dateutil-2.4.2-py2.py3-none-any.whl 3 pip install 绝对路径\matplotlib依赖\scipy-0.16.0-cp34-none-win_amd64.whl

使用python的包matplotlib来画图

6、验证是否安装成功: 1 在python编辑状态下导入安装的包: import matplotlib import nump烤恤鹇灭y import scipy import pyparsing import matplotlib.pyplot as plt 2 如果缺少six 在安装完毕scipy之后把../Python34/Lib/site-packages/scipy/lib中的six.py six.pyc six.pyo三个文件拷贝到.../Python34/Lib/site-packages

7、案例1:import matplotlib.pyplot as pltx = [0, 1, 2, 3, 4, 5]y = [0.1, 0.2, 0.2, 0.3, 0.2, 0.1]y2 = [0.2, 0.2, 0.3, 0.2, 0.3, 0]plt.plot(x, y, 'b', x, y2, 'g')plt.show()

使用python的包matplotlib来画图

8、案例2:import matplotlib.pyplot as pltimport mathx=[]y=[]num=0.0while num < math.pi * 4: y.append(math.sin(num)) x.append(num) num += 0.1 plt.plot(x, y, 'b')plt.show()如果

使用python的包matplotlib来画图
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢