Python pylab.fill_between() Examples

The following are 4 code examples of pylab.fill_between(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pylab , or try the search function .
Example #1
Source File: estimator_utils.py    From EDeN with MIT License 7 votes vote down vote up
def plot_stats(x=None, y=None, label=None, color='navy'):
    """plot_stats."""
    y = np.array(y)
    y0 = y[0]
    y1 = y[1]
    y2 = y[2]
    y3 = y[3]
    y4 = y[4]
    plt.fill_between(x, y3, y4, color=color, alpha=0.08)
    plt.fill_between(x, y1, y2, color=color, alpha=0.08)
    plt.plot(x, y0, '-', lw=2, color=color, label=label)
    plt.plot(x, y0,
             linestyle='None',
             markerfacecolor='white',
             markeredgecolor=color,
             marker='o',
             markeredgewidth=2,
             markersize=8) 
Example #2
Source File: util.py    From Azimuth with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def addqqplotinfo(qnull,M,xl='-log10(P) observed',yl='-log10(P) expected',xlim=None,ylim=None,alphalevel=0.05,legendlist=None,fixaxes=False):    
    distr='log10'
    pl.plot([0,qnull.max()], [0,qnull.max()],'k')
    pl.ylabel(xl)
    pl.xlabel(yl)
    if xlim is not None:
        pl.xlim(xlim)
    if ylim is not None:
        pl.ylim(ylim)        
    if alphalevel is not None:
        if distr == 'log10':
            betaUp, betaDown, theoreticalPvals = _qqplot_bar(M=M,alphalevel=alphalevel,distr=distr)
            lower = -sp.log10(theoreticalPvals-betaDown)
            upper = -sp.log10(theoreticalPvals+betaUp)
            pl.fill_between(-sp.log10(theoreticalPvals),lower,upper,color="grey",alpha=0.5)
            #pl.plot(-sp.log10(theoreticalPvals),lower,'g-.')
            #pl.plot(-sp.log10(theoreticalPvals),upper,'g-.')
    if legendlist is not None:
        leg = pl.legend(legendlist, loc=4, numpoints=1)
        # set the markersize for the legend
        for lo in leg.legendHandles:
            lo.set_markersize(10)

    if fixaxes:
        fix_axes() 
Example #3
Source File: megafacade.py    From facade-segmentation with MIT License 5 votes vote down vote up
def plot_facade_cuts(self):

        facade_sig = self.facade_edge_scores.sum(0)
        facade_cuts = find_facade_cuts(facade_sig, dilation_amount=self.facade_merge_amount)
        mu = np.mean(facade_sig)
        sigma = np.std(facade_sig)

        w = self.rectified.shape[1]
        pad=10

        gs1 = pl.GridSpec(5, 5)
        gs1.update(wspace=0.5, hspace=0.0)  # set the spacing between axes.

        pl.subplot(gs1[:3, :])
        pl.imshow(self.rectified)
        pl.vlines(facade_cuts, *pl.ylim(), lw=2, color='black')
        pl.axis('off')
        pl.xlim(-pad, w+pad)

        pl.subplot(gs1[3:, :], sharex=pl.gca())
        pl.fill_between(np.arange(w), 0, facade_sig, lw=0, color='red')
        pl.fill_between(np.arange(w), 0, np.clip(facade_sig, 0, mu+sigma), color='blue')
        pl.plot(np.arange(w), facade_sig, color='blue')

        pl.vlines(facade_cuts, facade_sig[facade_cuts], pl.xlim()[1], lw=2, color='black')
        pl.scatter(facade_cuts, facade_sig[facade_cuts])

        pl.axis('off')

        pl.hlines(mu, 0, w, linestyle='dashed', color='black')
        pl.text(0, mu, '$\mu$ ', ha='right')

        pl.hlines(mu + sigma, 0, w, linestyle='dashed', color='gray',)
        pl.text(0, mu + sigma, '$\mu+\sigma$ ', ha='right')
        pl.xlim(-pad, w+pad) 
Example #4
Source File: histfit.py    From fitter with GNU General Public License v3.0 4 votes vote down vote up
def fit(self, error_rate=0.05, semilogy=False, Nfit=100,
            error_kwargs={"lw":1, "color":"black", "alpha":0.2},
            fit_kwargs={"lw":2, "color":"red"}):
        self.mus = []
        self.sigmas = []
        self.amplitudes = []
        self.fits = []

        pylab.figure(1)
        pylab.clf()
        pylab.bar(self.X, self.Y, width=0.85, ec="k")

        for x in range(Nfit):
            # 10% error on the data to add errors 
            self.E = [scipy.stats.norm.rvs(0, error_rate) for y in self.Y]
            #[scipy.stats.norm.rvs(0, self.std_data * error_rate) for x in range(self.N)]
            self.result = scipy.optimize.least_squares(self.func, 
                (self.guess_mean, self.guess_std, self.guess_amp))

            mu, sigma, amplitude = self.result['x']
            pylab.plot(self.X, amplitude * scipy.stats.norm.pdf(self.X, mu,sigma),
                **error_kwargs)
            self.sigmas.append(sigma)
            self.amplitudes.append(amplitude)
            self.mus.append(mu)


            self.fits.append(amplitude * scipy.stats.norm.pdf(self.X, mu,sigma))

        self.sigma = mean(self.sigmas)
        self.amplitude = mean(self.amplitudes)
        self.mu = mean(self.mus)


        pylab.plot(self.X, self.amplitude * scipy.stats.norm.pdf(self.X, self.mu, self.sigma), 
                   **fit_kwargs)
        if semilogy:
            pylab.semilogy() 
        pylab.grid()

        pylab.figure(2)
        pylab.clf()
        #pylab.bar(self.X, self.Y, width=0.85, ec="k", alpha=0.5)
        M = mean(self.fits, axis=0)
        S = pylab.std(self.fits, axis=0)
        pylab.fill_between(self.X, M-3*S, M+3*S, color="gray", alpha=0.5)
        pylab.fill_between(self.X, M-2*S, M+2*S, color="gray", alpha=0.5)
        pylab.fill_between(self.X, M-S, M+S, color="gray", alpha=0.5)
        #pylab.plot(self.X, M-S, color="k")
        #pylab.plot(self.X, M+S, color="k")
        pylab.plot(self.X, self.amplitude * scipy.stats.norm.pdf(self.X, self.mu, self.sigma), 
                   **fit_kwargs)
        pylab.grid()

        return self.mu, self.sigma, self.amplitude