【问题标题】:What is a difference between "pylab" and "matplotlib.pyplot"?“pylab”和“matplotlib.pyplot”有什么区别?
【发布时间】:2013-01-11 16:47:21
【问题描述】:

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

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

【问题讨论】:

标签: python matplotlib


【解决方案1】:

来自official 文档:

Pylab 将 pyplot 功能(用于绘图)与 numpy 功能(用于数学和使用数组) 单个命名空间,使该命名空间(或环境)更加 类似于 MATLAB。例如,可以调用 sin 和 cos 函数 就像您在 MATLAB 中一样,并且具有以下所有功能 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-13
    • 2016-08-08
    • 2010-10-02
    • 2011-12-12
    • 2010-09-16
    • 2012-03-14
    • 2012-02-06
    • 2011-02-25
    相关资源
    最近更新 更多