2
我总是使用ser.plot(xticks=range(0, len(ser), step), ..)
来绘制指定xticks的图形。但是,在带有标签的Series
时,它在熊猫0.17中不起作用。下面是代码:这是熊猫0.17中`Series.plot`的bug吗?
In [1]: from numpy import random as rnd
In [2]: import pandas as pd
In [3]: pd.__version__
Out[3]: '0.17.0'
In [4]: %matplotlib inline
In [5]: rnd.seed(123)
In [6]: ser = pd.Series(rnd.randn(73).cumsum(), index=['P%02d' % i for i in range(73)])
In [7]: ser.plot(figsize=(9, 6), rot=60, title='Figure without xticks')
Out[7]: <matplotlib.axes._subplots.AxesSubplot at 0x8370198
In [8]ser.plot(figsize=(9, 6), xticks=list(range(0, 73, 6)), rot=60, title='Figure with xticks')
Out[8]: <matplotlib.axes._subplots.AxesSubplot at 0x83e9940>
而在熊猫0.16同一代码:
In [1]: from numpy import random as rnd
In [2]: import pandas as pd
In [3]: pd.__version__
Out[3]: '0.16.0'
In [4]: %matplotlib inline
In [5]: rnd.seed(123)
In [6]: ser = pd.Series(rnd.randn(73).cumsum(), index=['P%02d' % i for i in range(73)])
In [8]: ser.plot(figsize=(9, 6), xticks=list(range(0, 73, 6)), rot=60, title='Figure with xticks')
Out[8]: <matplotlib.axes._subplots.AxesSubplot at 0xbbf19b0>