Plot sediment accumulation rate prior and posterior distributions

def plot_sediment_rate(self, ax=None):
        """Plot sediment accumulation rate prior and posterior distributions"""
        if ax is None:
            ax = plt.gca()

        y_prior, x_prior = self.prior_sediment_rate()
        ax.plot(x_prior, y_prior, label='Prior')

        y_posterior = self.mcmcfit.sediment_rate
        density = scipy.stats.gaussian_kde(y_posterior.flat)
        density.covariance_factor = lambda: 0.25
        density._compute_covariance()
        ax.plot(x_prior, density(x_prior), label='Posterior')

        acc_shape = self.mcmcsetup.mcmc_kws['acc_shape']
        acc_mean = self.mcmcsetup.mcmc_kws['acc_mean']
        annotstr_template = 'acc_shape: {0}\nacc_mean: {1}'
        annotstr = annotstr_template.format(acc_shape, acc_mean)
        ax.annotate(annotstr, xy=(0.9, 0.9), xycoords='axes fraction',
                    horizontalalignment='right', verticalalignment='top')

        ax.set_ylabel('Density')
        ax.set_xlabel('Acc. rate (yr/cm)')
        ax.grid(True)
        return ax