gpt4 book ai didi

python - "pylab"和 "matplotlib.pyplot"有什么区别?

转载 作者:太空宇宙 更新时间:2023-11-03 15:21:09 26 4
gpt4 key购买 nike

我尝试使用 MatPlotLib,我意识到可以用两种不同的方式导入它,并且在这两种情况下它都有效(以相同的方式):import pylab as pimport matplotlib .pyplot 作为 p

那么,我的问题是这两种方式有什么区别?

最佳答案

来自official文档:

Pylab combines the pyplot functionality (for plotting) with the numpy functionality (for mathematics and for working with arrays) in a single namespace, making that namespace (or environment) even more MATLAB-like. For example, one can call the sin and cos functions just like you could in MATLAB, as well as having all the features of pyplot.

请注意,pylab 仅从顶级 numpy 命名空间导入。因此,这将起作用

import numpy
numpy.array # works
numpy.distutils # finds a module

这不会

import pylab
pylab.array # works, is actually numpy array
pylab.distutils # gives an error

关于python - "pylab"和 "matplotlib.pyplot"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560477/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com