python - 理解(并查找)matplotlib 源代码

标签 python matplotlib plot

在这里,matplotlib 的频谱图返回 4 个变量,其中最后一个是绘图:

http://matplotlib.org/examples/pylab_examples/specgram_demo.html

但这里似乎元组中只返回了 3 个变量:

https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/mlab.py#L478

缺少生成频谱图的代码在哪里?也许我只是对 pylab 和 matplotlib 之间的区别感到困惑。无论如何,我找不到来源。

最佳答案

您将计算要绘制的数据的函数与绘制数据的函数混淆了。

mlab.specgram 仅计算数据,而 axis 方法 specgram 绘制数据。

看看:https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes/_axes.py#L5786

ipython 对于这样的事情非常有用。 method_name? 将显示相关文档和源文件的位置,而 method_name?? 还将显示相关代码。

理解 matplotlib 函数的源代码可能有点令人困惑。基本上,matplotlib.pyplot 中的任何内容都是自动生成的。本质上,所有绘图方法实际上都是 Axes 对象的方法。

希望这能让您开始。如果没有其他人给出更好的答案,当我有更多时间时,我会详细说明。

关于python - 理解(并查找)matplotlib 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19505454/

相关文章:

python - 使用单个 plt.bar() 函数设置条形图标签和值

python - matplotlib 等高线图 : proportional colorbar levels in logarithmic scale

wolfram-mathematica - 对数图

r - 如何通过 R 创建 GUI?

python - 理解 Python 中的 for 循环

python - 如何在运行方法中没有循环的情况下终止 Python 中的线程?

python - 为什么对象不需要 global 关键字

python - 通过 matplotlib 图表绘制 pandas 数据框并在图表上绘制点

python - 使用具有 > 2 个参数的用户定义函数的 matplotlib 绘制 3d 曲面

python - Docker 无法找到满足要求的版本 mysqlclient == 2.0.3