windows 7 64 bits matplotlib的安装和简单测试

来源:互联网 发布:旺格子软件 编辑:程序博客网 时间:2024/05/22 15:30

环境配置过程中所需要的软件包等

http://pan.baidu.com/s/1nt5jIhr、下列软件包是基于64位的python,matplotlib、numpy、scipy等均为64位版



1、安装Python2.7,安装过程中选择仅供当前用户使用,这样可以避免安装matplotlib.exe时出现Python未注册的错误。配置python环境变量

2、安装wheel、使用pip install wheel

3、安装numpy、使用wheel install numpy-1.9.2-*文件的全路径

4、安装scipy、同上使用wheel install命令

5、安装matplotlib、直接双击exe文件,如果第一步选择的是当前用户而不是所有用户,此步骤就不会报未注册的错误

6、除了上面的软件包,还需要安装上述包运行所需要的基础包,如six、dateutil、pyparsing等

7、安装six,只需要使用pip install six 、同样安装pyparsing也使用相同的命令

8、安装dateutil的时候,pip install python-dateutil

测试,是否安装成功

[code=python]

import numpy as np
import matplotlib.pyplot as plt
 
N = 5
menMeans = (20, 35, 30, 35, 27)
menStd =   (2, 3, 4, 1, 2)
 
ind = np.arange(N)  # the x locations for the groups
width = 0.35       # the width of the bars
 
fig, ax = plt.subplots()
rects1 = ax.bar(ind, menMeans, width, color='r', yerr=menStd)
 
womenMeans = (25, 32, 34, 20, 25)
womenStd =   (3, 5, 2, 3, 3)
rects2 = ax.bar(ind+width, womenMeans, width, color='y', yerr=womenStd)
 
# add some
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind+width)
ax.set_xticklabels( ('G1', 'G2', 'G3', 'G4', 'G5') )
 
ax.legend( (rects1[0], rects2[0]), ('Men', 'Women') )
 
def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%d'%int(height),
                ha='center', va='bottom')
 
autolabel(rects1)
autolabel(rects2)
 
plt.show()

[/code]

复制上述python代码,保存为 test.py

在windows cmd环境下cd到test.py文件目录,执行python test.py

显示图形效果如下:


环境搭建成功!

0 0
原创粉丝点击