Confusion Between Numpy, Scipy, Matplotlib And Pylab
Solution 1:
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.
Solution 2:
Scipy and numpy are scientific projects whose aim is to bring efficient and fast numeric computing to python.
Matplotlib is the name of the python plotting library.
Pyplot is an interactive api for matplotlib, mostly for use in notebooks like jupyter. You generally use it like this: import matplotlib.pyplot as plt.
Pylab is the same thing as pyplot, but with extra features (its use is currently discouraged).
- pylab = pyplot + numpy
See more information here: Matplotlib, Pylab, Pyplot, etc: What's the difference between these and when to use each?
Solution 3:
Since some people (like me) may still be confused about usage of pylab since examples using pylab are out there on the internet, here is a quote from the official matplotlib FAQ:
pylab is a convenience module that bulk imports matplotlib.pyplot (for plotting) and numpy (for mathematics and working with arrays) in a single name space. Although many examples use pylab, it is no longer recommended.
So, TL;DR; is do not use pylab, period. Use pyplot and import numpy separately as needed.
Here is the link for further reading and other useful examples.
Post a Comment for "Confusion Between Numpy, Scipy, Matplotlib And Pylab"