Numpy, scipy, matplotlib, and pylab are common terms among they who use python for scientific computation.
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 *
the numpy will be imported as well (with np alias). So basically the second one does more things compared to the first one.
There are few things I want to ask:
- Is it right that pylab is just a wrapper for numpy, scipy and matplotlib?
- As np is the numpy alias in pylab, what is the scipy and matplotlib alias in pylab? (as far as I know, plt is alias of matplotlib.pyplot, but I don’t know the alias for the matplotlib itself)
No,
pylabis part ofmatplotlib(inmatplotlib.pylab) and tries to give you a MatLab like environment.matplotlibhas a number of dependencies, among themnumpywhich it imports under the common aliasnp.scipyis not a dependency ofmatplotlib.If you run
ipython --pylaban automatic import will put all symbols frommatplotlib.pylabinto global scope. Like you wrotenumpygets imported under thenpalias. Symbols frommatplotlibare available under themplalias.