Python pylab 模块,yticks() 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用pylab.yticks()

项目:f1_2017    作者:aflaisler    | 项目源码 | 文件源码
def plot_importance(names, model, savefig=True):
    featureNames = numpy.array(names)
    featureImportance = model.feature_importances_
    featureImportance = featureImportance / featureImportance.max()
    sorted_idx = numpy.argsort(featureImportance)
    barPos = numpy.arange(sorted_idx.shape[0]) + .5
    plot.barh(barPos, featureImportance[sorted_idx], align='center')
    plot.yticks(barPos, featureNames[sorted_idx])
    plot.xlabel('Variable Importance')
    plot.subplots_adjust(left=0.2, right=0.9, top=0.9, bottom=0.1)
    if savefig:
        dt_ = datetime.datetime.now().strftime('%d%b%y_%H%M')
        plt.savefig("../graphs/featureImportance_" + dt_ + ".png")
    plot.show()


# Plot prediction save the graph with a timestamp
项目:dotfiles    作者:zchee    | 项目源码 | 文件源码
def plot(self):
        """
        Plot startup data.
        """
        import pylab

        print("Plotting result...", end="")
        avg_data = self.average_data()
        avg_data = self.__sort_data(avg_data, False)
        if len(self.raw_data) > 1:
            err = self.stdev_data()
            sorted_err = [err[k] for k in list(zip(*avg_data))[0]]
        else:
            sorted_err = None
        pylab.barh(range(len(avg_data)), list(zip(*avg_data))[1],
                   xerr=sorted_err, align='center', alpha=0.4)
        pylab.yticks(range(len(avg_data)), list(zip(*avg_data))[0])
        pylab.xlabel("Average startup time (ms)")
        pylab.ylabel("Plugins")
        pylab.show()
        print(" done.")
项目:adversarial-autoencoder    作者:musyoku    | 项目源码 | 文件源码
def scatter_labeled_z(z_batch, label_batch, filename="labeled_z"):
    fig = pylab.gcf()
    fig.set_size_inches(20.0, 16.0)
    pylab.clf()
    colors = ["#2103c8", "#0e960e", "#e40402","#05aaa8","#ac02ab","#aba808","#151515","#94a169", "#bec9cd", "#6a6551"]
    for n in range(z_batch.shape[0]):
        result = pylab.scatter(z_batch[n, 0], z_batch[n, 1], c=colors[label_batch[n]], s=40, marker="o", edgecolors='none')

    classes = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    recs = []
    for i in range(0, len(colors)):
        recs.append(mpatches.Rectangle((0, 0), 1, 1, fc=colors[i]))

    ax = pylab.subplot(111)
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    ax.legend(recs, classes, loc="center left", bbox_to_anchor=(1.1, 0.5))
    pylab.xticks(pylab.arange(-4, 5))
    pylab.yticks(pylab.arange(-4, 5))
    pylab.xlabel("z1")
    pylab.ylabel("z2")
    pylab.savefig(filename)
项目:chainer-adversarial-autoencoder    作者:fukuta0614    | 项目源码 | 文件源码
def visualize_reconstruction(xp, model, x, visualization_dir, epoch, gpu=False):
    x_variable = chainer.Variable(xp.asarray(x))
    _x = model.decode(model.encode(x_variable), test=True)
    _x.to_cpu()
    _x = _x.data

    fig = pylab.gcf()
    fig.set_size_inches(8.0, 8.0)
    pylab.clf()
    pylab.gray()
    for m in range(50):
        i = m / 10
        j = m % 10
        pylab.subplot(10, 10, 20 * i + j + 1, xticks=[], yticks=[])
        pylab.imshow(x[m].reshape((28, 28)), interpolation="none")
        pylab.subplot(10, 10, 20 * i + j + 10 + 1, xticks=[], yticks=[])
        pylab.imshow(_x[m].reshape((28, 28)), interpolation="none")
        # pylab.imshow(np.clip((_x_batch.data[m] + 1.0) / 2.0, 0.0, 1.0).reshape(
        # (config.img_channel, config.img_width, config.img_width)), interpolation="none")
        pylab.axis("off")
    pylab.savefig("{}/reconstruction_{}.png".format(visualization_dir, epoch))
    # pylab.show()
项目:fang    作者:rgrosse    | 项目源码 | 文件源码
def plot_eigenspectrum(G, s, nvis, nhid):
    with misc.gnumpy_conversion_check('allow'):
        dim = G.shape[0]
        d, Q = scipy.linalg.eigh(G)
        d = d[::-1]
        Q = Q[:, ::-1]

        pts = np.unique(np.floor(np.logspace(0., np.log10(dim-1), 500)).astype(int)) - 1

        cf = [fisher.correlation_fraction(Q[:, i], s, nvis, nhid) for i in pts]

        pylab.figure()
        pylab.subplot(2, 1, 1)
        pylab.loglog(range(1, dim+1), d, 'b-', lw=2.)
        pylab.xticks([])
        pylab.yticks(fontsize='large')

        pylab.subplot(2, 1, 2)
        pylab.semilogx(pts+1, cf, 'r-', lw=2.)
        pylab.xticks(fontsize='x-large')
        pylab.yticks(fontsize='large')
项目:adgm    作者:musyoku    | 项目源码 | 文件源码
def plot_z(z, dir=None, filename="z", xticks_range=None, yticks_range=None):
    if dir is None:
        raise Exception()
    try:
        os.mkdir(dir)
    except:
        pass
    fig = pylab.gcf()
    fig.set_size_inches(16.0, 16.0)
    pylab.clf()
    for n in xrange(z.shape[0]):
        result = pylab.scatter(z[n, 0], z[n, 1], s=40, marker="o", edgecolors='none')
    pylab.xlabel("z1")
    pylab.ylabel("z2")
    if xticks_range is not None:
        pylab.xticks(pylab.arange(-xticks_range, xticks_range + 1))
    if yticks_range is not None:
        pylab.yticks(pylab.arange(-yticks_range, yticks_range + 1))
    pylab.savefig("{}/{}.png".format(dir, filename))
项目:bokeh_roc_slider    作者:brianray    | 项目源码 | 文件源码
def plot(self,title='',include_baseline=False,equal_aspect=True):
        """ Method that generates a plot of the ROC curve
            Parameters:
                title: Title of the chart
                include_baseline: Add the baseline plot line if it's True
                equal_aspect: Aspects to be equal for all plot
        """

        pylab.clf()
        pylab.plot([x[0] for x in self.derived_points], [y[1] for y in self.derived_points], self.linestyle)
        if include_baseline:
            pylab.plot([0.0,1.0], [0.0,1.0],'k-.')
        pylab.ylim((0,1))
        pylab.xlim((0,1))
        pylab.xticks(pylab.arange(0,1.1,.1))
        pylab.yticks(pylab.arange(0,1.1,.1))
        pylab.grid(True)
        if equal_aspect:
            cax = pylab.gca()
            cax.set_aspect('equal')
        pylab.xlabel('1 - Specificity')
        pylab.ylabel('Sensitivity')
        pylab.title(title)

        pylab.show()
项目:variational-autoencoder    作者:musyoku    | 项目源码 | 文件源码
def visualize_labeled_z(z_batch, label_batch, dir=None):
    fig = pylab.gcf()
    fig.set_size_inches(20.0, 16.0)
    pylab.clf()
    colors = ["#2103c8", "#0e960e", "#e40402","#05aaa8","#ac02ab","#aba808","#151515","#94a169", "#bec9cd", "#6a6551"]
    for n in xrange(z_batch.shape[0]):
        result = pylab.scatter(z_batch[n, 0], z_batch[n, 1], c=colors[label_batch[n]], s=40, marker="o", edgecolors='none')

    classes = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    recs = []
    for i in range(0, len(colors)):
        recs.append(mpatches.Rectangle((0, 0), 1, 1, fc=colors[i]))

    ax = pylab.subplot(111)
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    ax.legend(recs, classes, loc="center left", bbox_to_anchor=(1.1, 0.5))
    pylab.xticks(pylab.arange(-4, 5))
    pylab.yticks(pylab.arange(-4, 5))
    pylab.xlabel("z1")
    pylab.ylabel("z2")
    pylab.savefig("%s/labeled_z.png" % dir)
项目:seqhawkes    作者:mlukasik    | 项目源码 | 文件源码
def align_subplots(
    N,
    M,
    xlim=None,
    ylim=None,
    ):
    """make all of the subplots have the same limits, turn off unnecessary ticks"""

    # find sensible xlim,ylim

    if xlim is None:
        xlim = [np.inf, -np.inf]
        for i in range(N * M):
            pb.subplot(N, M, i + 1)
            xlim[0] = min(xlim[0], pb.xlim()[0])
            xlim[1] = max(xlim[1], pb.xlim()[1])
    if ylim is None:
        ylim = [np.inf, -np.inf]
        for i in range(N * M):
            pb.subplot(N, M, i + 1)
            ylim[0] = min(ylim[0], pb.ylim()[0])
            ylim[1] = max(ylim[1], pb.ylim()[1])

    for i in range(N * M):
        pb.subplot(N, M, i + 1)
        pb.xlim(xlim)
        pb.ylim(ylim)
        if i % M:
            pb.yticks([])
        else:
            removeRightTicks()
        if i < M * (N - 1):
            pb.xticks([])
        else:
            removeUpperTicks()
项目:SegmentationService    作者:jingchaoluan    | 项目源码 | 文件源码
def showgrid(l,cols=None,n=400,titles=None,xlabels=None,ylabels=None,**kw):
    if "cmap" not in kw: kw["cmap"] = cm.gray
    if "interpolation" not in kw: kw["interpolation"] = "nearest"
    n = minimum(n,len(l))
    if cols is None: cols = int(sqrt(n))
    rows = (n+cols-1)//cols
    for i in range(n):
        pylab.xticks([]) ;pylab.yticks([])
        pylab.subplot(rows,cols,i+1)
        pylab.imshow(l[i],**kw)
        if titles is not None: pylab.title(str(titles[i]))
        if xlabels is not None: pylab.xlabel(str(xlabels[i]))
        if ylabels is not None: pylab.ylabel(str(ylabels[i]))
项目:astromalign    作者:dstndstn    | 项目源码 | 文件源码
def plotaffinegrid(affines, exag=1e3, affineOnly=True, R=0.025, tpre='', bboxes=None):
    import pylab as plt
    NR = 3
    NC = int(ceil(len(affines)/3.))
    #R = 0.025 # 1.5 arcmin
    #for (exag,affonly) in [(1e2, False), (1e3, True), (1e4, True)]:
    plt.clf()
    for i,aff in enumerate(affines):
        plt.subplot(NR, NC, i+1)
        dl = aff.refdec - R
        dh = aff.refdec + R
        rl = aff.refra  - R / aff.rascale
        rh = aff.refra  + R / aff.rascale
        RR,DD = np.meshgrid(np.linspace(rl, rh, 11),
                            np.linspace(dl, dh, 11))
        plotaffine(aff, RR.ravel(), DD.ravel(), exag=exag, affineOnly=affineOnly,
                   doclf=False,
                   units='dots', width=2, headwidth=2.5, headlength=3, headaxislength=3)
        if bboxes is not None:
            for bb in bboxes:
                plt.plot(*bb, linestyle='-', color='0.5')
            plt.plot(*bboxes[i], linestyle='-', color='k')
        setRadecAxes(rl,rh,dl,dh)
        plt.xlabel('')
        plt.ylabel('')
        plt.xticks([])
        plt.yticks([])
        plt.title('field %i' % (i+1))
    plt.subplots_adjust(left=0.05, right=0.95, wspace=0.1)
    if affineOnly:
        tt = tpre + 'Affine part of transformations'
    else:
        tt = tpre + 'Transformations'
    plt.suptitle(tt + ' (x %g)' % exag)
项目:BinarizationService    作者:jingchaoluan    | 项目源码 | 文件源码
def showgrid(l,cols=None,n=400,titles=None,xlabels=None,ylabels=None,**kw):
    if "cmap" not in kw: kw["cmap"] = cm.gray
    if "interpolation" not in kw: kw["interpolation"] = "nearest"
    n = minimum(n,len(l))
    if cols is None: cols = int(sqrt(n))
    rows = (n+cols-1)//cols
    for i in range(n):
        pylab.xticks([]) ;pylab.yticks([])
        pylab.subplot(rows,cols,i+1)
        pylab.imshow(l[i],**kw)
        if titles is not None: pylab.title(str(titles[i]))
        if xlabels is not None: pylab.xlabel(str(xlabels[i]))
        if ylabels is not None: pylab.ylabel(str(ylabels[i]))
项目:chainer-adversarial-autoencoder    作者:fukuta0614    | 项目源码 | 文件源码
def visualize_10_2d_gaussian_prior(n_z, y_label, visualization_dir=None):
    z_batch = sample_z_from_n_2d_gaussian_mixture(len(y_label), n_z, y_label, 10, False)
    z_batch = z_batch.data

    fig = pylab.gcf()
    fig.set_size_inches(15, 12)
    pylab.clf()
    colors = ["#2103c8", "#0e960e", "#e40402", "#05aaa8", "#ac02ab", "#aba808", "#151515", "#94a169", "#bec9cd",
              "#6a6551"]
    for n in xrange(z_batch.shape[0]):
        result = pylab.scatter(z_batch[n, 0], z_batch[n, 1], c=colors[y_label[n]], s=40, marker="o",
                               edgecolors='none')

    classes = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    recs = []
    for i in range(0, len(colors)):
        recs.append(mpatches.Rectangle((0, 0), 1, 1, fc=colors[i]))

    ax = pylab.subplot(111)
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    ax.legend(recs, classes, loc="center left", bbox_to_anchor=(1.1, 0.5))
    pylab.xticks(pylab.arange(-4, 5))
    pylab.yticks(pylab.arange(-4, 5))
    pylab.xlabel("z1")
    pylab.ylabel("z2")
    if visualization_dir is not None:
        pylab.savefig("%s/10_2d-gaussian.png" % visualization_dir)
    pylab.show()
项目:chainer-adversarial-autoencoder    作者:fukuta0614    | 项目源码 | 文件源码
def visualize_labeled_z(xp, model, x, y_label, visualization_dir, epoch, gpu=False):
    x = chainer.Variable(xp.asarray(x))
    z_batch = model.encode(x, test=True)
    z_batch.to_cpu()
    z_batch = z_batch.data
    fig = pylab.gcf()
    fig.set_size_inches(8.0, 8.0)
    pylab.clf()
    colors = ["#2103c8", "#0e960e", "#e40402", "#05aaa8", "#ac02ab", "#aba808", "#151515", "#94a169", "#bec9cd",
              "#6a6551"]
    for n in xrange(z_batch.shape[0]):
        result = pylab.scatter(z_batch[n, 0], z_batch[n, 1], c=colors[y_label[n]], s=40, marker="o",
                               edgecolors='none')

    classes = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
    recs = []
    for i in range(0, len(colors)):
        recs.append(mpatches.Rectangle((0, 0), 1, 1, fc=colors[i]))

    ax = pylab.subplot(111)
    box = ax.get_position()
    ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
    ax.legend(recs, classes, loc="center left", bbox_to_anchor=(1.1, 0.5))
    pylab.xticks(pylab.arange(-4, 5))
    pylab.yticks(pylab.arange(-4, 5))
    pylab.xlabel("z1")
    pylab.ylabel("z2")
    pylab.savefig("{}/labeled_z_{}.png".format(visualization_dir, epoch))
    # pylab.show()
项目:deep_ocr    作者:JinpengLI    | 项目源码 | 文件源码
def showgrid(l,cols=None,n=400,titles=None,xlabels=None,ylabels=None,**kw):
    if "cmap" not in kw: kw["cmap"] = cm.gray
    if "interpolation" not in kw: kw["interpolation"] = "nearest"
    n = minimum(n,len(l))
    if cols is None: cols = int(sqrt(n))
    rows = (n+cols-1)//cols
    for i in range(n):
        pylab.xticks([]) ;pylab.yticks([])
        pylab.subplot(rows,cols,i+1)
        pylab.imshow(l[i],**kw)
        if titles is not None: pylab.title(str(titles[i]))
        if xlabels is not None: pylab.xlabel(str(xlabels[i]))
        if ylabels is not None: pylab.ylabel(str(ylabels[i]))
项目:PyME    作者:vikramsunkara    | 项目源码 | 文件源码
def plot_marginals(state_space,p,name,t,labels = False,interactive = False):
    import matplotlib

    import matplotlib.pyplot as pl
    if interactive == True: 
        pl.ion()
    pl.clf()
    pl.suptitle("time: "+ str(t)+" units")
    #print("time : "+ str(t))
    D = state_space.shape[1]

    for i in range(D):
        marg_X = np.unique(state_space[:,i])
        A = np.where(marg_X[:,np.newaxis] == state_space[:,i].T[np.newaxis,:],1,0)
        marg_p = np.dot(A,p)
        pl.subplot(int(D/2)+1,2,i+1)
        pl.plot(marg_X,marg_p)
        pl.yticks(np.linspace(np.amin(marg_p), np.amax(marg_p), num=3))
        pl.axvline(np.sum(marg_X*marg_p),color= 'r')
        pl.axvline(marg_X[np.argmax(marg_p)],color='g')
        if labels == False:
            pl.xlabel("Specie: " + str(i+1))
        else:
            pl.xlabel(labels[i])
    if interactive == True:
        pl.draw()
    else:
        pl.tight_layout()
        pl.show()
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def drawHessDiagram(self,catalog=None):
        ax = plt.gca()
        if not catalog: catalog = self.get_stars()

        r_peak = self.kernel.extension
        angsep = ugali.utils.projector.angsep(self.ra, self.dec, catalog.ra, catalog.dec)
        cut_inner = (angsep < r_peak)
        cut_annulus = (angsep > 0.5) & (angsep < 1.) # deg

        mmin, mmax = 16., 24.
        cmin, cmax = -0.5, 1.0
        mbins = np.linspace(mmin, mmax, 150)
        cbins = np.linspace(cmin, cmax, 150)

        color = catalog.color[cut_annulus]
        mag = catalog.mag[cut_annulus]

        h, xbins, ybins = numpy.histogram2d(color, mag, bins=[cbins,mbins])
        blur = nd.filters.gaussian_filter(h.T, 2)
        kwargs = dict(extent=[xbins.min(),xbins.max(),ybins.min(),ybins.max()],
                      cmap='gray_r', aspect='auto', origin='lower', 
                      rasterized=True, interpolation='none')
        ax.imshow(blur, **kwargs)

        pylab.scatter(catalog.color[cut_inner], catalog.mag[cut_inner], 
                      c='red', s=7, edgecolor='none')# label=r'$r < %.2f$ deg'%(r_peak))
        ugali.utils.plotting.drawIsochrone(self.isochrone, c='b', zorder=10)
        ax.set_xlim(-0.5, 1.)
        ax.set_ylim(24., 16.)
        plt.xlabel(r'$g - r$')
        plt.ylabel(r'$g$')
        plt.xticks([-0.5, 0., 0.5, 1.])
        plt.yticks(numpy.arange(mmax - 1., mmin - 1., -1.))

        radius_string = (r'${\rm r}<%.1f$ arcmin'%( 60 * r_peak))
        pylab.text(0.05, 0.95, radius_string, 
                   fontsize=10, ha='left', va='top', color='red', 
                   transform=pylab.gca().transAxes,
                   bbox=dict(facecolor='white', alpha=1., edgecolor='none'))
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def drawMembersSpatial(self,data):
        ax = plt.gca()
        if isinstance(data,basestring):
            filename = data
            data = pyfits.open(filename)[1].data

        xmin, xmax = -0.25,0.25
        ymin, ymax = -0.25,0.25
        xx,yy = np.meshgrid(np.linspace(xmin,xmax),np.linspace(ymin,ymax))

        x_prob, y_prob = sphere2image(self.ra, self.dec, data['RA'], data['DEC'])

        sel = (x_prob > xmin)&(x_prob < xmax) & (y_prob > ymin)&(y_prob < ymax)
        sel_prob = data['PROB'][sel] > 5.e-2
        index_sort = numpy.argsort(data['PROB'][sel][sel_prob])

        plt.scatter(x_prob[sel][~sel_prob], y_prob[sel][~sel_prob], 
                      marker='o', s=2, c='0.75', edgecolor='none')
        sc = plt.scatter(x_prob[sel][sel_prob][index_sort], 
                         y_prob[sel][sel_prob][index_sort], 
                         c=data['PROB'][sel][sel_prob][index_sort], 
                         marker='o', s=10, edgecolor='none', cmap='jet', vmin=0., vmax=1.) # Spectral_r

        drawProjImage(xx,yy,None,coord='C')

        #ax.set_xlim(xmax, xmin)
        #ax.set_ylim(ymin, ymax)
        #plt.xlabel(r'$\Delta \alpha_{2000}\,(\deg)$')
        #plt.ylabel(r'$\Delta \delta_{2000}\,(\deg)$')
        plt.xticks([-0.2, 0., 0.2])
        plt.yticks([-0.2, 0., 0.2])

        divider = make_axes_locatable(ax)
        ax_cb = divider.new_horizontal(size="7%", pad=0.1)
        plt.gcf().add_axes(ax_cb)
        pylab.colorbar(sc, cax=ax_cb, orientation='vertical', ticks=[0, 0.2, 0.4, 0.6, 0.8, 1.0], label='Membership Probability')
        ax_cb.yaxis.tick_right()
项目:ImageTransformer    作者:ssingal05    | 项目源码 | 文件源码
def showFourier(self):
        psd2D = np.log(np.abs(self.four)**2+1)
        (height,width) = psd2D.shape
        py.figure(figsize=(10,10*height/width),facecolor='white')
        py.clf()
        py.rc('text',usetex=True)
        py.xlabel(r'$\omega_1$',fontsize=24)
        py.ylabel(r'$\omega_2$',fontsize=24)
        py.xticks(fontsize=16)
        py.yticks(fontsize=16)
        py.imshow( psd2D, cmap='Greys_r',extent=[-pi,pi,-pi,pi],aspect='auto')
        py.show()
项目:fang    作者:rgrosse    | 项目源码 | 文件源码
def plot_results(self, results, xloc, color, ls, label):
        iter_counts = sorted(set([it for it, av in results.keys() if av == self.average]))
        sorted_results = [results[it, self.average] for it in iter_counts]

        avg = np.array([r.train_logprob() for r in sorted_results])
        if hasattr(r, 'train_logprob_interval'):
            lower = np.array([r.train_logprob_interval()[0] for r in sorted_results])
            upper = np.array([r.train_logprob_interval()[1] for r in sorted_results])

        if self.logscale:
            plot_cmd = pylab.semilogx
        else:
            plot_cmd = pylab.plot

        xloc = xloc[:len(avg)]

        lw = 2.

        if label not in self.labels:
            plot_cmd(xloc, avg, color=color, ls=ls, lw=lw, label=label)
        else:
            plot_cmd(xloc, avg, color=color, ls=ls, lw=lw)

        self.labels.add(label)

        pylab.xticks(fontsize='xx-large')
        pylab.yticks(fontsize='xx-large')

        try:
            pylab.errorbar(xloc, (lower+upper)/2., yerr=(upper-lower)/2., fmt='', ls='None', ecolor=color)
        except:
            pass
项目:spyking-circus-ort    作者:spyking-circus    | 项目源码 | 文件源码
def view_rates(self, indices=None, spacing=1):
        res = self.synthetic_store.get(indices=indices, variables='r')
        pylab.figure()
        for key in res.keys():
            colorVal = self._scalarMap_synthetic.to_rgba(int(key))
            pylab.plot(res[key]['r'] + int(key)*spacing, color=colorVal)
        pylab.xlabel('Time [chunks]')
        pylab.yticks([], [])
        pylab.show()
项目:spyking-circus-ort    作者:spyking-circus    | 项目源码 | 文件源码
def view_synthetic_templates(self, indices=None, time=None, nn=100, hf_dist=45, a_dist=1.0):

        if indices is None:
            indices = range(self.nb_cells)

        if not numpy.iterable(indices):
            indices = [indices]

        scaling = None
        pylab.figure()

        for i in indices:

            template   = self._get_synthetic_template(i, time, nn, hf_dist, a_dist)
            template   = template.toarray()
            width      = template.shape[1]
            xmin, xmax = self.probe.field_of_view['x_min'], self.probe.field_of_view['x_max']
            ymin, ymax = self.probe.field_of_view['y_min'], self.probe.field_of_view['y_max']
            if scaling is None:
                scaling= 10*numpy.max(numpy.abs(template))
            colorVal   = self._scalarMap_synthetic.to_rgba(i)

            for count, i in enumerate(xrange(self.nb_channels)):
                x, y     = self.probe.positions[:, i]
                xpadding = ((x - xmin)/(float(xmax - xmin) + 1))*(2*width)
                ypadding = ((y - ymin)/(float(ymax - ymin) + 1))*scaling
                pylab.plot(xpadding + numpy.arange(width), ypadding + template[i, :], color=colorVal)

        pylab.tight_layout()
        pylab.setp(pylab.gca(), xticks=[], yticks=[])
        pylab.xlim(xmin, 3*width)
        pylab.show()
项目:spyking-circus-ort    作者:spyking-circus    | 项目源码 | 文件源码
def view_circus_templates(self, indices=None):

        if indices is None:
            indices = range(self.nb_templates)

        if not numpy.iterable(indices):
            indices = [indices]

        data      = self.template_store.get(indices, ['templates', 'norms'])
        width     = self.template_store.width
        templates = data.pop('templates').T
        norms     = data.pop('norms')
        scaling   = None
        pylab.figure()

        for count, i in enumerate(indices):

            template   = templates[count].toarray().reshape(self.nb_channels, width) * norms[count]
            xmin, xmax = self.probe.field_of_view['x_min'], self.probe.field_of_view['x_max']
            ymin, ymax = self.probe.field_of_view['y_min'], self.probe.field_of_view['y_max']
            if scaling is None:
                scaling= 10*numpy.max(numpy.abs(template))
            colorVal   = self._scalarMap_circus.to_rgba(i)

            for count, i in enumerate(xrange(self.nb_channels)):
                x, y     = self.probe.positions[:, i]
                xpadding = ((x - xmin)/(float(xmax - xmin) + 1))*(2*width)
                ypadding = ((y - ymin)/(float(ymax - ymin) + 1))*scaling
                pylab.plot(xpadding + numpy.arange(width), ypadding + template[i, :], color=colorVal)

        pylab.tight_layout()
        pylab.setp(pylab.gca(), xticks=[], yticks=[])
        pylab.xlim(xmin, 3*width)
        pylab.show()
项目:Python-for-Finance-Second-Edition    作者:PacktPublishing    | 项目源码 | 文件源码
def graph(text,text2=''): 
    pl.xticks(())
    pl.yticks(())
    pl.xlim(0,30)
    pl.ylim(0,20) 
    pl.plot([x,x],[0,3])
    pl.text(x,-2,"X");
    pl.text(0,x,"X")
    pl.text(x,x*1.7, text, ha='center', va='center',size=10, alpha=.5) 
    pl.text(-5,10,text2,size=25)
项目:bokeh_roc_slider    作者:brianray    | 项目源码 | 文件源码
def plot_multiple_roc(rocList,title='',labels=None, include_baseline=False, equal_aspect=True):
    """ Plots multiple ROC curves on the same chart.
        Parameters:
            rocList: the list of ROCData objects
            title: The tile of the chart
            labels: The labels of each ROC curve
            include_baseline: if it's  True include the random baseline
            equal_aspect: keep equal aspect for all roc curves
    """
    pylab.clf()
    pylab.ylim((0,1))
    pylab.xlim((0,1))
    pylab.xticks(pylab.arange(0,1.1,.1))
    pylab.yticks(pylab.arange(0,1.1,.1))
    pylab.grid(True)
    if equal_aspect:
        cax = pylab.gca()
        cax.set_aspect('equal')
    pylab.xlabel("1 - Specificity")
    pylab.ylabel("Sensitivity")
    pylab.title(title)
    if not labels:
        labels = [ '' for x in rocList]
    _remove_duplicate_styles(rocList)
    for ix, r in enumerate(rocList):
        pylab.plot([x[0] for x in r.derived_points], [y[1] for y in r.derived_points], r.linestyle, linewidth=1, label=labels[ix])
    if include_baseline:
        pylab.plot([0.0,1.0], [0.0, 1.0], 'k-', label= 'random')
    if labels:
        pylab.legend(loc='lower right')

    pylab.show()
项目:svm-street-detector    作者:morris-frank    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:VOCSeg    作者:lxh-123    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:VOCSeg    作者:lxh-123    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:KittiSeg    作者:MarvinTeichmann    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:KittiSeg    作者:MarvinTeichmann    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:KittiSeg    作者:MarvinTeichmann    | 项目源码 | 文件源码
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def drawMembersCMD(self,data):
        ax = plt.gca()
        if isinstance(data,basestring):
            filename = data
            data = pyfits.open(filename)[1].data

        xmin, xmax = -0.25,0.25
        ymin, ymax = -0.25,0.25
        mmin, mmax = 16., 24.
        cmin, cmax = -0.5, 1.0
        mbins = np.linspace(mmin, mmax, 150)
        cbins = np.linspace(cmin, cmax, 150)

        mag_1 = data[self.config['catalog']['mag_1_field']]
        mag_2 = data[self.config['catalog']['mag_2_field']]

        x_prob, y_prob = sphere2image(self.ra, self.dec, data['RA'], data['DEC'])

        sel = (x_prob > xmin)&(x_prob < xmax) & (y_prob > ymin)&(y_prob < ymax)
        sel_prob = data['PROB'][sel] > 5.e-2
        index_sort = numpy.argsort(data['PROB'][sel][sel_prob])

        plt.scatter(data['COLOR'][sel][~sel_prob], mag_1[sel][~sel_prob],
              marker='o',s=2,c='0.75',edgecolor='none')
        sc = pylab.scatter(data['COLOR'][sel][sel_prob][index_sort], mag_1[sel][sel_prob][index_sort], 
                   c=data['PROB'][sel][sel_prob][index_sort], 
                   marker='o', s=10, edgecolor='none', cmap='jet', vmin=0., vmax=1) 
        pylab.xlim(cmin, cmax)
        pylab.ylim(mmax, mmin)
        pylab.xlabel(r'$g - r$')
        pylab.ylabel(r'$g$')
        #axes[1].yaxis.set_major_locator(MaxNLocator(prune='lower'))
        pylab.xticks([-0.5, 0., 0.5, 1.])
        pylab.yticks(numpy.arange(mmax - 1., mmin - 1., -1.))

        ugali.utils.plotting.drawIsochrone(self.isochrone, c='k', zorder=10)

        pylab.text(0.05, 0.95, r'$\Sigma p_{i} = %i$'%(data['PROB'].sum()),
                   fontsize=10, horizontalalignment='left', verticalalignment='top', color='k', transform=pylab.gca().transAxes,
                   bbox=dict(facecolor='white', alpha=1., edgecolor='none'))

        divider = make_axes_locatable(pylab.gca())
        ax_cb = divider.new_horizontal(size="7%", pad=0.1)
        plt.gcf().add_axes(ax_cb)
        pylab.colorbar(sc, cax=ax_cb, orientation='vertical', ticks=[0, 0.2, 0.4, 0.6, 0.8, 1.0], label='Membership Probability')
        ax_cb.yaxis.tick_right()