是否有将matplotlib的有状态pyplot API映射到等同于面向对象的文档的文档?

use*_*107 3 python matplotlib

我更喜欢使用Matplotlib的面向对象的API,直接在图形和轴上操作,而不是使用matplotlib.pyplot命令。

但是,我经常发现更容易找到通过pyplot界面执行操作的文档。在这些情况下pyplot,根据Figure和Axes方法找出相关命令的作用将非常有用,因为这将帮助我处理在寻找文档时遇到的任何特殊情况。

举例来说,plt.xlabel()相当于ax.set_xlabel()如果ax是在pyplot的状态界面中的“当前”轴。但是我在xlabel()文档中找不到任何提及Axes.set_xlabel()的内容。在这种情况下,在Axes文档中单独查找并不是很困难,但是映射会非常好。

是否有任何信息源可以告诉我每个特定pyplot命令在面向对象接口方面的作用?

Sto*_*ica 5

使用消息来源,卢克!许多pyplot逗号只是很薄的包装AxesFigure方法。我通常使用IPython。

In [1]: import matplotlib.pyplot as plt

In [2]: plt.xlabel??
Signature: plt.xlabel(s, *args, **kwargs)
Source:
def xlabel(s, *args, **kwargs):
    """
    Set the *x* axis label of the current axis.

    Default override is::

      override = {
          'fontsize'            : 'small',
          'verticalalignment'   : 'top',
          'horizontalalignment' : 'center'
          }

    .. seealso::

        :func:`~matplotlib.pyplot.text`
            For information on how override and the optional args work
    """
    return gca().set_xlabel(s, *args, **kwargs)
File:      ~\appdata\local\programs\python\python36-32\lib\site-packages\matplotlib\pyplot.py
Run Code Online (Sandbox Code Playgroud)