Series.plot
(或DataFrame.plot
)返回一个matplotlibaxis
对象,该对象公开了几种方法。例如:
a = ['a', 'a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'd', 'e', 'e', 'e', 'e', 'e']
ax = pd.Series(a).value_counts().sort_index().plot('bar')
ax.set_title("my title")
ax.set_xlabel("my x-label")
ax.set_ylabel("my y-label")
nb:熊猫在这里使用matplotlib作为依赖项,并公开matplotlib对象和api。您可以通过获得相同的结果import matplotlib.pyplot as plt; ax = plt.subplots(1,1,1)
。如果你曾经在一次创建一个以上的情节,你会发现ax.<method>
比模块级更为方便plt.title('my title')
,因为它定义它,你想情节标题变化,您可以采取的优势自动完成的ax
对象。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句