Numpy,scipy,matplotlib和pylab是使用python进行科学计算的常用术语 .
我只是学习了一下pylab,我感到很困惑 . 每当我想导入numpy时,我总能做到:
import numpy as np
我只是考虑,一旦我做了
from pylab import *
numpy也将被导入(使用 np
别名) . 所以基本上第二个与第一个相比做了更多的事情 .
我想问几件事:
-
pylab只是numpy,scipy和matplotlib的包装器吗?
-
由于np是pylab中的numpy别名,pylab中的scipy和matplotlib别名是什么? (据我所知,plt是matplotlib.pyplot的别名,但我不知道matplotlib本身的别名)
2 回答
不,
pylab
是matplotlib
(在matplotlib.pylab
中)的一部分,并尝试为您提供类似MatLab的环境 .matplotlib
有许多依赖项,其中numpy
是在公共别名np
下导入的 .scipy
不是matplotlib
的依赖项 .如果运行
ipython --pylab
,则自动导入会将matplotlib.pylab
中的所有符号放入全局范围 . 就像你写的numpy
在np
别名下导入 . 来自matplotlib
的符号可在mpl
别名下找到 .Scipy and numpy 是科学项目,其目的是为python带来高效,快速的数值计算 .
Matplotlib 是python绘图库的名称 .
Pyplot 是matplotlib的交互式api,主要用于像jupyter这样的笔记本 . 你通常这样使用它:
import matplotlib.pyplot as plt
.Pylab 与pyplot相同,但具有额外功能(目前不鼓励使用它) .
点击此处查看更多信息:Matplotlib, Pylab, Pyplot, etc: What's the difference between these and when to use each?