fedora 安装pylab 并简单绘制三角函数

pylab 由 三个部分组成:scipy, matplotlab, numpy三部分组成,安装时需要分别安装这三部分,在fedora中,可以使用命令:

sudo dnf install python-matplotlib python3-matplotlib
sudo dnf install scipy python3-scipy
sudo dnf install pylab python3-pylab

即可安装。

 

安装好后,可以简单尝试一下:

__author__ = 'emerald'

import numpy
import pylab

xVal = numpy.arange(0, 4 * numpy.pi, 0.1)
ySin = numpy.sin(xVal)  # y =sin(x)
yCos = numpy.cos(xVal)  # y = cos(x)
y3Cos = numpy.multiply(yCos, xVal)  #y = x * cos(x)
zero = numpy.multiply(yCos, 0)  # y = 0

pylab.title("Sine and Cosine plot")
pylab.plot(xVal, ySin, 'r')
pylab.plot(xVal, yCos, 'b')
pylab.plot(xVal, zero, '#000000')
pylab.plot(xVal, y3Cos, 'g')
pylab.show()

 

运行后可以看到:

posted @ 2015-09-17 21:08  Emerald  阅读(346)  评论(0编辑  收藏  举报