matplotlib:imshow有哪些可能的参数?

时间:2019-02-21 12:41:41

标签: python matplotlib data-structures arguments colormap

我很好奇更改颜色图和用于绘制矩阵的插值方法

import matplotlib.pyplot as plt
matrix= [[1,2,3],
         [4,5,6],
         [7,8,9]]
plt.imshow(matrix,cmap="gray")
plt.show()

plt.imshow的定义中(在文件pyplot.py中),如果找到此代码:

def imshow(
        X, cmap=None, norm=None, aspect=None, interpolation=None,
        alpha=None, vmin=None, vmax=None, origin=None, extent=None,
        shape=None, filternorm=1, filterrad=4.0, imlim=None,
        resample=None, url=None, *, data=None, **kwargs):
    __ret = gca().imshow(
        X, cmap=cmap, norm=norm, aspect=aspect,
        interpolation=interpolation, alpha=alpha, vmin=vmin,
        vmax=vmax, origin=origin, extent=extent, shape=shape,
        filternorm=filternorm, filterrad=filterrad, imlim=imlim,
        resample=resample, url=url, **({"data": data} if data is not
        None else {}), **kwargs)
    sci(__ret)
    return __ret

但是它只说cmap=Noneinterpolation=None

我知道我可以在互联网上查找这些参数的选项(例如https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods.html), 但是我想在matplotib本身的python代码中找到cmap和内插的选项可能性,也希望对python中的数据结构更加熟悉。

如何在代码中“挖掘”这些参数的选项?

作为IDE,我正在使用pycharm。

2 个答案:

答案 0 :(得分:1)

在您的python会话中

Test-Connection

在jupyter笔记本中

Format-Table

不了解pycharm

答案 1 :(得分:0)

我建议使用matplotlib的在线文档,该文档可从matplotlib.org获得。

在主页上,您可以导航到 API

enter image description here

然后查看matplotlib.pyplot function referencelist of matplotlib modules

然后,您将进入被认证的文档页面

从那里您可以获得有关可能的参数和可接受值的完整概述。您可以直接检查源代码

enter image description here

并经常找到链接的用法示例。