有没有办法在做pandas.DataFrame.plot()时控制网格格式?
具体来说,我想显示用于绘制具有日期时间索引的x轴的DataFrame的次要网格线.
这可以通过DataFrame.plot()吗?
df = pd.DataFrame.from_csv(csv_file, parse_dates=True, sep=' ')
Bastiaan.. 17
也许这个功能去年不存在,但在版本0.19.2中你可以这样做:
df.plot(grid=True)
见文档.
这将以每周频率为S&p500绘制少量xticks和网格:
import pandas.io.data as web ts = web.DataReader("^GSPC", "yahoo", start=dt.date( 2013, 6, 1 ))[ 'Adj Close' ] ax = ts.plot() xtick = pd.date_range( start=ts.index.min( ), end=ts.index.max( ), freq='W' ) ax.set_xticks( xtick, minor=True ) ax.grid('on', which='minor', axis='x' ) ax.grid('off', which='major', axis='x' )
也许这个功能去年不存在,但在版本0.19.2中你可以这样做:
df.plot(grid=True)
见文档.