numpy,scipy,matplotlib和pylab之间的混淆 [英] Confusion between numpy, scipy, matplotlib and pylab

查看:124
本文介绍了numpy,scipy,matplotlib和pylab之间的混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用python进行科学计算的人中,numpy,scipy,matplotlib和pylab是常见术语.

Numpy, scipy, matplotlib, and pylab are common terms among they who use python for scientific computation.

我只是学习了一些有关pylab的知识,我感到困惑. 每当我想导入numpy时,我总是可以做到:

I just learn a bit about pylab, and I got confused. Whenever I want to import numpy, I can always do:

import numpy as np

我只是考虑,一旦我这样做

I just consider, that once I do

from pylab import *

numpy也将被导入(使用np别名).因此基本上,第二个相比第一个做更多的事情.

the numpy will be imported as well (with np alias). So basically the second one does more things compared to the first one.

我想问的几件事:

  1. pylab只是numpy,scipy和matplotlib的包装吗?
  2. 由于NP是pylab中的numpy别名,因此pylab中的scipy和matplotlib别名是什么? (据我所知,plt是matplotlib.pyplot的别名,但我不知道matplotlib本身的别名)

推荐答案

  1. 否,pylabmatplotlib的一部分(在matplotlib.pylab中),并试图为您提供类似MatLab的环境. matplotlib有许多依赖项,其中有numpy个依赖项,它以通用别名np导入. scipy不是matplotlib的依赖项.

  1. No, pylab is part of matplotlib (in matplotlib.pylab) and tries to give you a MatLab like environment. matplotlib has a number of dependencies, among them numpy which it imports under the common alias np. scipy is not a dependency of matplotlib.

如果运行ipython --pylab,则自动导入会将matplotlib.pylab中的所有符号放入全局范围.就像您写的那样,numpy被导入为np别名.在mpl别名下可以使用matplotlib中的符号.

If you run ipython --pylab an automatic import will put all symbols from matplotlib.pylab into global scope. Like you wrote numpy gets imported under the np alias. Symbols from matplotlib are available under the mpl alias.

这篇关于numpy,scipy,matplotlib和pylab之间的混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆