Pandas: How to display minor grid lines on x-axis in pd.DataFrame.plot()
pandas, plot, python
Solution
this will plot S&p500 with minor xticks and grids at weekly frequency:
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' )
Problem
Is there a way to control grid format when doing pandas.DataFrame.plot()? Specifically i would like to show the minor gridlines for plotting a DataFrame with a x-axis which has a DateTimeIndex. Is this possible through the DataFrame.plot()? ``` df = pd.DataFrame.from_csv(csv_file, parse_dates=True, sep=' ') ```