【发布时间】:2013-01-04 16:13:42
【问题描述】:
在 Matplotlib 中,很多示例以 ax = subplot(111) 的形式出现,然后函数应用于 ax,例如 ax.xaxis.set_major_formatter(FuncFormatter(myfunc))。 (找到here)
或者,当我不需要子图时,我可以只做plt.figure(),然后用plt.plot() 或类似函数绘制我需要的任何东西。
现在,我正好是第二种情况,但我想在 X 轴上调用函数set_major_formatter。在plt 上调用它当然行不通:
>>> plt.xaxis.set_major_formatter(FuncFormatter(myfunc))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'xaxis'
我应该在这里做什么?
【问题讨论】:
-
我希望我能多次投票...我还没有“打破表面”并真正理解子情节和数字背后的推理以及为什么子情节似乎具有更大的“力量”即能力配置等
标签: python graph matplotlib plot