`
jgsj
  • 浏览: 960671 次
文章分类
社区版块
存档分类
最新评论

windows7下使用64位Python编程、科学计算、绘制图表

 
阅读更多

介绍windows7 64位系统下使用python。

1、下载并安装64版本的python2.7。下载地址:点击打开链接

一直“下一步”即可安装完成。完成后,就可以使用python GUI编程了。

2、下载科学计算扩展包,Numpy。下载地址:点击打开链接

Numpy 是一个 Python 的扩展模块,通过使用 NumPy,我们可以进行科学计算。NumPy 提供了矩阵、线性代数、傅里叶变换等的解决方法。

NumPy包含:

1)N维矩阵对象

2)线性代数运算功能

3)傅里叶变换

4)Fortran代码集成的工具

5) C++代码集成的工具

3、下载扩展包matplotlib,下载地址:点击打开链接

matplotlib是一个在python下实现的类matlab 的纯python 的三方库。Matplotlib 可以绘制多种形式的图形包括普通的线图,直方图,饼图,散点图以及误差线图等。

4、简单绘图:

绘图只需要导入matplotlib扩展包即可:

import matplotlib.pyplot as plt

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


5、绘制复杂图标例子

#!/usr/bin/env python
'''Demonstration of LineCollection, PolyCollection, and
RegularPolyCollection with autoscaling.

For the first two subplots, we will use spirals.  Their
size will be set in plot units, not data units.  Their positions
will be set in data units by using the "offsets" and "transOffset"
kwargs of the LineCollection and PolyCollection.

The third subplot will make regular polygons, with the same
type of scaling and positioning as in the first two.

The last subplot illustrates the use of "offsets=(xo,yo)",
that is, a single tuple instead of a list of tuples, to generate
successively offset curves, with the offset given in data
units.  This behavior is available only for the LineCollection.

'''

import matplotlib.pyplot as P
from matplotlib import collections, axes, transforms
from matplotlib.colors import colorConverter
import numpy as N

nverts = 50
npts = 100

# Make some spirals
r = N.array(range(nverts))
theta = N.array(range(nverts)) * (2*N.pi)/(nverts-1)
xx = r * N.sin(theta)
yy = r * N.cos(theta)
spiral = zip(xx,yy)

# Make some offsets
rs = N.random.RandomState([12345678])
xo = rs.randn(npts)
yo = rs.randn(npts)
xyo = zip(xo, yo)

# Make a list of colors cycling through the rgbcmyk series.
colors = [colorConverter.to_rgba(c) for c in ('r','g','b','c','y','m','k')]

fig = P.figure()

a = fig.add_subplot(2,2,1)
col = collections.LineCollection([spiral], offsets=xyo,
                                transOffset=a.transData)
trans = fig.dpi_scale_trans + transforms.Affine2D().scale(1.0/72.0)
col.set_transform(trans)  # the points to pixels transform
    # Note: the first argument to the collection initializer
    # must be a list of sequences of x,y tuples; we have only
    # one sequence, but we still have to put it in a list.
a.add_collection(col, autolim=True)
    # autolim=True enables autoscaling.  For collections with
    # offsets like this, it is neither efficient nor accurate,
    # but it is good enough to generate a plot that you can use
    # as a starting point.  If you know beforehand the range of
    # x and y that you want to show, it is better to set them
    # explicitly, leave out the autolim kwarg (or set it to False),
    # and omit the 'a.autoscale_view()' call below.

# Make a transform for the line segments such that their size is
# given in points:
col.set_color(colors)

a.autoscale_view()  # See comment above, after a.add_collection.
a.set_title('LineCollection using offsets')


# The same data as above, but fill the curves.

a = fig.add_subplot(2,2,2)

col = collections.PolyCollection([spiral], offsets=xyo,
                                transOffset=a.transData)
trans = transforms.Affine2D().scale(fig.dpi/72.0)
col.set_transform(trans)  # the points to pixels transform
a.add_collection(col, autolim=True)
col.set_color(colors)


a.autoscale_view()
a.set_title('PolyCollection using offsets')

# 7-sided regular polygons

a = fig.add_subplot(2,2,3)

col = collections.RegularPolyCollection(7,
                                        sizes = N.fabs(xx)*10.0, offsets=xyo,
                                        transOffset=a.transData)
trans = transforms.Affine2D().scale(fig.dpi/72.0)
col.set_transform(trans)  # the points to pixels transform
a.add_collection(col, autolim=True)
col.set_color(colors)
a.autoscale_view()
a.set_title('RegularPolyCollection using offsets')


# Simulate a series of ocean current profiles, successively
# offset by 0.1 m/s so that they form what is sometimes called
# a "waterfall" plot or a "stagger" plot.

a = fig.add_subplot(2,2,4)

nverts = 60
ncurves = 20
offs = (0.1, 0.0)

yy = N.linspace(0, 2*N.pi, nverts)
ym = N.amax(yy)
xx = (0.2 + (ym-yy)/ym)**2 * N.cos(yy-0.4) * 0.5
segs = []
for i in range(ncurves):
    xxx = xx + 0.02*rs.randn(nverts)
    curve = zip(xxx, yy*100)
    segs.append(curve)

col = collections.LineCollection(segs, offsets=offs)
a.add_collection(col, autolim=True)
col.set_color(colors)
a.autoscale_view()
a.set_title('Successive data offsets')
a.set_xlabel('Zonal velocity component (m/s)')
a.set_ylabel('Depth (m)')
# Reverse the y-axis so depth increases downward
a.set_ylim(a.get_ylim()[::-1])


P.show()


分享到:
评论

相关推荐

    Python 科学计算

    Python 科学计算 目 录 3.5.1 中值滤波.....................................97 3.5.2 滤波器设计.................................98 3.6 图像处理——ndimage .................100 3.6.1 膨胀和腐蚀..............

    python常用库介绍

    当谈论到Python编程中的常用库时,有许多强大的工具可供选择,可以根据你的需求来选择使用哪些库。NumPy:用于科学计算的基础包,提供了高性能的多维数组对象和用于数组操作的工具。 Pandas:用于数据分析和处理的...

    在Linux下使用Python的matplotlib绘制数据图的教程

    大量的文档和例子、集成了Python和Numpy科学计算包、以及自动化能力,是作为Linux环境中进行科学画图的可靠选择的几个原因。这个教程将提供几个用matplotlib画图的例子。 特性 支持众多的图表类型,如:bar,box,...

    Python For Everyone, 3rd Edition

    Python for Everyone,第 3 版是对编程的介绍,旨在满足广泛的学生兴趣和能力,侧重于基本要素和有效学习。它适用于计算机科学家、工程师和其他学科学生的编程入门课程。本书不需要任何编程经验,只需要少量的高中...

    Python库大揭秘:20个不可不知的AI神器技术关键词:Python、TensorFlow、PyTorch

    适用人群: 本文适合对Python编程感兴趣的人,特别是那些想要进入人工智能、机器学习、数据科学等领域的开发者。无论你是初学者还是有一定经验的开发者,这些Python库都能为你的项目提供强大的支持。 使用场景及目标...

    Python Matplotlib库入门指南

    Matplotlib是一个Python工具箱,用于科学计算的数据可视化。借助它,Python可以绘制如Matlab和Octave多种多样的数据图形。最初是模仿了Matlab图形命令, 但是与Matlab是相互独立的. 通过Matplotlib中简单的接口可以...

    8位16位64位等任意数量用户CDMA直接序列扩频通信系统的Matlab仿真.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    基于MATLAB编程环境的行人检测系统,.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    此系统主要是对心电图的分析与共享,使得医生和市民可以共享心电图.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用MATLAB开发的量化回测系统.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用matlab模拟信号与系统中的校正装置.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用matlab的实现声音分离系统和图像处理系统.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    这是一个使用MATLAB制作的简易图像处理系统.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    这是一个使用Matlab对超市排队系统进行模拟仿真项目.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用Matlab实现PID控制器,对一个二阶系统进行控制。.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用Matlab和Yalmip进行电力系统维护的模型,包括分支机构和发电机的维护,并且分支机构可以进行部分维护.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    基于牛顿迭代法和PQ分解法实现电力系统常规潮流计算,算例数据基于美国西部9节点系统(WSCC9).zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    使用肤色颜色空间建模+连通域处理及分析和Harr-cascade 方法进行人脸检测.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    基于MATLAB的倒车仿真系统及改进(R2018a).zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

    详解MATLAB Simulink通信系统建模与仿真 源码.zip

    如果您下载了本程序,但是该程序存在问题无法运行,那么您...总之,MATLAB是科学家、工程师和技术人员进行科研、教育和工业应用不可或缺的强大工具之一,尤其在需要大量数值计算和复杂系统建模的场景下发挥着重要作用。

Global site tag (gtag.js) - Google Analytics