'Plots the curve of rolling Sharpe ratio.'

def _plot_rolling_sharpe(self, stats, ax=None, **kwargs):

    def format_two_dec(x, pos):
        return ('%.2f' % x)
    sharpe = stats['rolling_sharpe']
    if (ax is None):
        ax = plt.gca()
    y_axis_formatter = FuncFormatter(format_two_dec)
    ax.yaxis.set_major_formatter(FuncFormatter(y_axis_formatter))
    ax.xaxis.set_tick_params(reset=True)
    ax.yaxis.grid(linestyle=':')
    ax.xaxis.set_major_locator(mdates.YearLocator(1))
    ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
    ax.xaxis.grid(linestyle=':')
    if (self.benchmark is not None):
        benchmark = stats['rolling_sharpe_b']
        benchmark.plot(lw=2, color='gray', label=self.benchmark, alpha=0.6, ax=ax, **kwargs)
    sharpe.plot(lw=2, color='green', alpha=0.6, x_compat=False, label='Backtest', ax=ax, **kwargs)
    ax.axvline(sharpe.index[252], linestyle='dashed', c='gray', lw=2)
    ax.set_ylabel('Rolling    Annualised    Sharpe')
    ax.legend(loc='best')
    ax.set_xlabel('')
    plt.setp(ax.get_xticklabels(), visible=True, rotation=0, ha='center')
    return ax
