Confusion between numpy, scipy, matplotlib and pylab

前端 未结 3 1841
执念已碎
执念已碎 2020-12-22 15:34

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. Whenev

相关标签:
3条回答
  • 2020-12-22 15:51
    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.

    2. 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.

    0 讨论(0)
  • 2020-12-22 15:59

    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.

    0 讨论(0)
  • 2020-12-22 16:04

    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?

    0 讨论(0)
提交回复
热议问题