def plot_MCMC_model(ax, xdata, ydata, trace):
 ax.plot(xdata, ydata, 'ok')
 (alpha, beta) = trace[:2]
 xfit = np.linspace((-20), 120, 10)
 yfit = (alpha[:, None] + (beta[:, None] * xfit))
 mu = yfit.mean(0)
 sig = (2 * yfit.std(0))
 ax.plot(xfit, mu, '-k')
 ax.fill_between(xfit, (mu - sig), (mu + sig), color='lightgray')
 ax.set_xlabel('x')
 ax.set_ylabel('y')

def plot_MCMC_model ( ax , xdata , ydata , trace ) : ax . plot ( xdata , ydata , 'ok' ) ( alpha , beta ) = trace [ : 2 ] xfit = np . linspace ( ( - 20 ) , 120 , 10 ) yfit = ( alpha [ : , None ] + ( beta [ : , None ] * xfit ) ) mu = yfit . mean ( 0 ) sig = ( 2 * yfit . std ( 0 ) ) ax . plot ( xfit , mu , '-k' ) ax . fill_between ( xfit , ( mu - sig ) , ( mu + sig ) , color = 'lightgray' ) ax . set_xlabel ( 'x' ) ax . set_ylabel ( 'y' )
plot the linear model and 2sigma contours .