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 pylabxVal = 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 = 0pylab.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()
运行后可以看到: