title: how to highlight weekends in matplotlib plots?
body: <p>For a simple time series:</p>
  
  <pre><code>import pandas as pd
  df = pd.DataFrame({'dt':['2020-01-01', '2020-01-02', '2020-01-04', '2020-01-05', '2020-01-06'], 'foo':[1,2, 4,5,6]})
  df['dt'] = pd.to_datetime(df.dt)
  df['dt_label']= df['dt'].dt.strftime('%Y-%m-%d %a')
  df = df.set_index('dt')
  #display(df)
  df['foo'].plot()
  x =plt.xticks(ticks=df.reset_index().dt.values, labels=df.dt_label, rotation=90, horizontalalignment='right')
  </code></pre>
  
  <p>How can I highlight the x-axis labels for weekends?</p>
  
  <h1>edit</h1>
  
  <p><a href="https://stackoverflow.com/questions/16480232/pandas-plots-separate-color-for-weekends-pretty-printing-times-on-x-axis/16624246">Pandas Plots: Separate color for weekends, pretty printing times on x axis</a></p>
  
  <p>suggests:</p>
  
  <pre><code>def highlight_weekends(ax, timeseries):
      d = timeseries.dt
      ranges = timeseries[d.dayofweek &gt;= 5].groupby(d.year * 100 + d.weekofyear).agg(['min', 'max'])
      for i, tmin, tmax in ranges.itertuples():
          ax.axvspan(tmin, tmax, facecolor='orange', edgecolor='none', alpha=0.1)
  </code></pre>
  
  <p>but applying it with</p>
  
  <pre><code>highlight_weekends(ax, df.reset_index().dt)
  </code></pre>
  
  <p>will not change the plot</p>