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

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

项目:yt    作者:yt-project    | 项目源码 | 文件源码
def plot_rgb(image, name, label=None, label_color='w', label_size='large'):
    """
    This will plot the r,g,b channels of an *image* of shape (N,M,3) or
    (N,M,4).  *name* is the prefix of the file name, which will be supplemented
    with "_rgb.png."  *label*, *label_color* and *label_size* may also be
    specified.
    """
    import pylab
    Nvec = image.shape[0]
    image[np.isnan(image)] = 0.0
    if image.shape[2] >= 4:
        image = image[:,:,:3]
    pylab.clf()
    pylab.gcf().set_dpi(100)
    pylab.gcf().set_size_inches((Nvec/100.0, Nvec/100.0))
    pylab.gcf().subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0, wspace=0.0, hspace=0.0)
    pylab.imshow(image, interpolation='nearest')
    if label is not None:
        pylab.text(20, 20, label, color = label_color, size=label_size) 
    pylab.savefig("%s_rgb.png" % name)
    pylab.clf()
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def disp(iimg, label = "", gray=False):
    """ Display an image using pylab
    """
    try:
        import pylab
        dimage = iimg.copy()
        if iimg.ndim==3:
            dimage[...,0] = iimg[...,2]
            dimage[...,2] = iimg[...,0]

        pylab.imshow(dimage, interpolation='none')
        if gray: pylab.gray()
        #pylab.gca().format_coord = format_coord
        pylab.text(1500, -30, label)
        pylab.axis('off')
        pylab.show()
    except ImportError:
        print "Module pylab not available"
项目:Captcha-recognition-TF    作者:dukn    | 项目源码 | 文件源码
def view_(_pred,_lable):

    fname = ['Captcha/lv3/%i.jpg' %i for i in range(20)]
    img = []
    for fn in fname:
        img.append(Image.open(open(fn)))
        #img.append(misc.imread(fn).astype(np.float))
    for i in range(len(img)):
        pylab.subplot(4,5,i+1); pylab.axis('off')

        pylab.imshow(img[i])
        #pylab.imshow( np.dot(np.array(img[i])[...,:3],[0.299,0.587,0.114]) , cmap=plt.get_cmap("gray"))
        #pylab.text(40,60,_pred[i],color = 'b')
        if ( _pred[i] == _lable[i] ):
            pylab.text(40,65,_pred[i],color = 'b',size = 15)
        else:
            pylab.text(40,65,_pred[i],color = 'r',size = 15)

        pylab.text(40,92,_lable[i],color = 'g',size = 15)

    pylab.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show(self):
#        pl.semilogy(self.theta, self.omega)
#                , label = '$L =%.1f m, $'%self.l + '$dt = %.2f s, $'%self.dt + '$\\theta_0 = %.2f radians, $'%self.theta[0] + '$q = %i, $'%self.q + '$F_D = %.2f, $'%self.F_D + '$\\Omega_D = %.1f$'%self.Omega_D)
        pl.plot(self.theta_phase ,self.omega_phase, '.', label = '$t \\approx 2\\pi n / \\Omega_D$')
        pl.xlabel('$\\theta$ (radians)')
        pl.ylabel('$\\omega$ (radians/s)')
        pl.legend()
#        pl.text(-1.4, 0.3, '$\\omega$ versus $\\theta$ $F_D = 1.2$', fontsize = 'x-large')
        pl.title('Chaotic Regime')
#        pl.show()
#        pl.semilogy(self.time_array, self.delta)
#        pl.legend(loc = 'upper center', fontsize = 'small')
#        pl.xlabel('$time (s)$')
#        pl.ylabel('$\\Delta\\theta (radians)$')
#        pl.xlim(0, self.T)
#        pl.ylim(float(input('ylim-: ')),float(input('ylim+: ')))
#        pl.ylim(1E-11, 0.01)
#        pl.text(4, -0.15, 'nonlinear pendulum - Euler-Cromer method')
#        pl.text(10, 1E-3, '$\\Delta\\theta versus time F_D = 0.5$')
#        pl.title('Simple Harmonic Motion')
        pl.title('Chaotic Regime')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_log(self):
#        pl.subplot(121)
        pl.semilogy(self.time_array, self.delta, 'c')
        pl.xlabel('$time (s)$')
        pl.ylabel('$\\Delta\\theta$ (radians)')
        pl.xlim(0, self.T)
#        pl.ylim(1E-11, 0.01)
        pl.text(42, 1E-7, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
        pl.title('Chaotic Regime')
        pl.show()

#    def show_log_sub122(self):
#        pl.subplot(122)
#        pl.semilogy(self.time_array, self.delta, 'g')
#        pl.xlabel('$time (s)$')
#        pl.ylabel('$\\Delta\\theta$ (radians)')
#        pl.xlim(0, self.T)
#        pl.ylim(1E-6, 100)
#        pl.text(20, 1E-5, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
#        pl.title('Chaotic Regime')
#        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show(self):
#        pl.semilogy(self.theta, self.omega)
#                , label = '$L =%.1f m, $'%self.l + '$dt = %.2f s, $'%self.dt + '$\\theta_0 = %.2f radians, $'%self.theta[0] + '$q = %i, $'%self.q + '$F_D = %.2f, $'%self.F_D + '$\\Omega_D = %.1f$'%self.Omega_D)
        pl.plot(self.time_array,self.delta)

#        pl.show()
#        pl.semilogy(self.time_array, self.delta)
#        pl.legend(loc = 'upper center', fontsize = 'small')
#        pl.xlabel('$time (s)$')
#        pl.ylabel('$\\Delta\\theta (radians)$')
#        pl.xlim(0, self.T)
#        pl.ylim(float(input('ylim-: ')),float(input('ylim+: ')))
#        pl.ylim(1E-11, 0.01)
#        pl.text(4, -0.15, 'nonlinear pendulum - Euler-Cromer method')
#        pl.text(10, 1E-3, '$\\Delta\\theta versus time F_D = 0.5$')
#        pl.title('Simple Harmonic Motion')
#        pl.title('Chaotic Regime')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_log(self):
#        pl.subplot(121)
        pl.semilogy(self.time_array, self.delta, 'c')
        pl.xlabel('$time (s)$')
        pl.ylabel('$\\Delta\\theta$ (radians)')
        pl.xlim(0, self.T)
#        pl.ylim(1E-11, 0.01)
        pl.text(42, 1E-7, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
        pl.title('Chaotic Regime')
        pl.show()

#    def show_log_sub122(self):
#        pl.subplot(122)
#        pl.semilogy(self.time_array, self.delta, 'g')
#        pl.xlabel('$time (s)$')
#        pl.ylabel('$\\Delta\\theta$ (radians)')
#        pl.xlim(0, self.T)
#        pl.ylim(1E-6, 100)
#        pl.text(20, 1E-5, '$\\Delta\\theta$ versus time $F_D = 1.2$', fontsize = 'x-large')
#        pl.title('Chaotic Regime')
#        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_complex(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 16,
        }
        pl.title('The Trajectory of Tageted Baseball\n with air flow in adiabatic model', fontdict = font)
        pl.plot(self.x, self.y, label = '$v_0 = %.5f m/s$'%self.v0 + ', ' + '$\\theta = %.4f \degree$'%self.theta)
        pl.xlabel('x $m$')
        pl.ylabel('y $m$')
        pl.xlim(0, 300)
        pl.ylim(-100, 20)
        pl.grid()
        pl.legend(loc = 'upper right', shadow = True, fontsize = 'small')
        pl.text(15, -90, 'scan to approach the minimum velocity and corresponding launching angle', fontdict = font)
        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_results(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 14,
        }
        pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
        pl.title('The Trajectory of a Cannon Shell', fontdict = font)
        pl.xlabel('x (k$m$)')
        pl.ylabel('y ($km$)')
        pl.xlim(0, 60)
        pl.ylim(0, 20)
        pl.grid(True)
        pl.legend(loc='upper right', shadow=True, fontsize='large')
        pl.text(41, 16, 'Only with air drag', fontdict = font)
        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_results(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 12,
        }
        pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
        pl.title('The Trajectory of a Cannon Shell', fontdict = font)
        pl.xlabel('x (k$m$)')
        pl.ylabel('y ($km$)')
        pl.xlim(0, 60)
        pl.ylim(0, 20)
        pl.grid(True)
        pl.legend(loc='upper right', shadow=True, fontsize='large')
        pl.text(34, 16, '       With both air drag and \n reduced air density-isothermal', fontdict = font)
        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_results(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 12,
        }
        pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
        pl.title('The Trajectory of a Cannon Shell', fontdict = font)
        pl.xlabel('x (k$m$)')
        pl.ylabel('y ($km$)')
        pl.xlim(0, 60)
        pl.ylim(0, 20)
        pl.grid(True)
        pl.legend(loc='upper right', shadow=True, fontsize='large')
        pl.text(34.5, 16, '      With air drag and the \n dependence of g on altitude', fontdict = font)
        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_results(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 12,
        }
        pl.plot(self.x, self.y, 'c', label='firing angle = 45°')
        pl.title('The Trajectory of a Cannon Shell', fontdict = font)
        pl.xlabel('x (k$m$)')
        pl.ylabel('y ($km$)')
        pl.xlim(0, 60)
        pl.ylim(0, 20)
        pl.grid(True)
        pl.legend(loc='upper right', shadow=True, fontsize='large')
        pl.text(34.5, 16, '       With both air drag and \n reduced air density-adiabatic', fontdict = font)
        pl.show()
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def drawSmoothCatalog(self, catalog, label=None, **kwargs):
        ax = plt.gca()
        ra,dec = catalog.ra_dec
        x, y = sphere2image(self.ra,self.dec,ra,dec)

        delta_x = self.radius/100.
        smoothing = 2*delta_x
        bins = numpy.arange(-self.radius, self.radius + 1.e-10, delta_x)
        h, xbins, ybins = numpy.histogram2d(x, y, bins=[bins, bins])
        blur = nd.filters.gaussian_filter(h.T, smoothing / delta_x)

        defaults = dict(cmap='gray_r',rasterized=True)
        kwargs = dict(defaults.items()+kwargs.items())

        xx,yy = np.meshgrid(xbins,ybins)
        im = drawProjImage(xx,yy,blur,coord='C',**kwargs)

        if label:
            plt.text(0.05, 0.95, label, fontsize=10, ha='left', va='top', 
                     color='k', transform=pylab.gca().transAxes,
                     bbox=dict(facecolor='white', alpha=1., edgecolor='none'))
项目:bokeh_roc_slider    作者:brianray    | 项目源码 | 文件源码
def plot_multiple_rocs_separate(rocList,title='', labels = None, equal_aspect = True):
    """ Plot multiples ROC curves as separate at the same painting area. """
    pylab.clf()
    pylab.title(title)
    for ix, r in enumerate(rocList):
        ax = pylab.subplot(4,4,ix+1)
        pylab.ylim((0,1))
        pylab.xlim((0,1))
        ax.set_yticklabels([])
        ax.set_xticklabels([])
        if equal_aspect:
            cax = pylab.gca()
            cax.set_aspect('equal')

        if not labels:
            labels = ['' for x in rocList]

        pylab.text(0.2,0.1,labels[ix],fontsize=8)
        pylab.plot([x[0] for x in r.derived_points],[y[1] for y in r.derived_points], 'r-',linewidth=2)

    pylab.show()
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def annotateImg(img, color, size, position, text):
    cv2.putText(img, text, position, cv2.FONT_HERSHEY_PLAIN, size, color, thickness = 2)
    return img
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def genside (img1, img2, height, width, name1, name2, txt1, txt2):
    """
    create a side-by-side view
    img1, img2: images
    name1, name2: their names 
    txt1, txt2: some text
    """
        if len(img1.shape)==2:
            cimg1 = np.zeros((img1.shape[0], img1.shape[1], 3), dtype=np.uint8)
            cimg1[...,0] = img1
            cimg1[...,1] = img1
            cimg1[...,2] = img1
        else:
            cimg1 = img1
        if len(img2.shape)==2:
            cimg2 = np.zeros((img2.shape[0], img2.shape[1], 3), dtype=np.uint8)
            cimg2[...,0] = img2
            cimg2[...,1] = img2
            cimg2[...,2] = img2
        else:
            cimg2 = img2

    if annotated:
        cimg1=annotateImg(cimg1, (0,0,255), 2, (100, 70), 'Source: '+name1)
        #cimg1=annotateImg(cimg1, (0,0,255), 2, (100, 130), txt1)
        cimg2=annotateImg(cimg2, (0,0,255), 2, (100, 70), 'Target: '+name2)
        #cimg2=annotateImg(cimg2, (0,0,255), 2, (100, 130), txt2)
        cimg = mergeSide(cimg1, cimg2)
    if annotated:
        cimg=annotateImg(cimg, (0,255,0), 2, (100, 130), txt1)
        return cimg
项目:office-interoperability-tools    作者:milossramek    | 项目源码 | 文件源码
def genoverlay(img1, title, name1, name2, stattxt, img2=None):
    """
    create an overlayed view
    img1, img2: images
    title: kind of title to print
    name1, name2: their names 
    txt: text to print below the title
    """

    if img2 is None:
        outimg = 255*(1-img1)
    else:
            s=np.maximum(img1.shape,img2.shape)
                outimg=np.zeros((s[0], s[1], 3), dtype=np.uint8)
                #outimg[:img1.shape[0], :img1.shape[1],0] = (255*(1-img1))
                #outimg[:img2.shape[0], :img2.shape[1],1] = (255*(1-img2))
                #outimg[:img2.shape[0], :img2.shape[1],2] = (255*(1-img2))
                outimg[:img1.shape[0], :img1.shape[1],0] = img1
                outimg[:img2.shape[0], :img2.shape[1],1] = img2
                outimg[:img2.shape[0], :img2.shape[1],2] = img2
                outimg = 255*(1-outimg)
    if annotated:
            outimg = annotateImg(outimg, (0, 0, 255), 2, (100, 50), title)
        txt = "cyan: %s %s"%(sourceid,name1)
            outimg = annotateImg(outimg, (0, 255, 255), 2, (100, 80), txt)
        txt = "red: %s %s"%(targetid,name2)
            outimg = annotateImg(outimg, (255, 0, 0), 2, (100, 110), txt)
        #outimg=annotateImg(outimg, 'blue', mm2px(4), mm2px(4), txt)
            outimg = annotateImg(outimg, (0, 0, 255), 1.3, (100, 140), stattxt)
    return outimg
项目:facade-segmentation    作者:jfemiani    | 项目源码 | 文件源码
def plot(self, bgimage=None):
        import pylab as pl

        self._plot_background(bgimage)
        ax = pl.gca()
        y0, y1 = pl.ylim()
        # r is the width of the thick line we use to show the facade colors
        r = 5
        patch = pl.Rectangle((self.facade_left + r, self.sky_line + r),
                             self.width - 2 * r,
                             self.door_line - self.sky_line - 2 * r,
                             color=self.color, fill=False, lw=2 * r)
        ax.add_patch(patch)

        pl.text((self.facade_right + self.facade_left) / 2.,
                (self.door_line + self.sky_line) / 2.,
                '$\sigma^2={:0.2f}$'.format(self.uncertainty_for_windows()))

        patch = pl.Rectangle((self.facade_left + r, self.door_line + r),
                             self.width - 2 * r,
                             y0 - self.door_line - 2 * r,
                             color=self.mezzanine_color, fill=False, lw=2 * r)
        ax.add_patch(patch)

        # Plot the left and right edges in yellow
        pl.vlines([self.facade_left, self.facade_right], self.sky_line, y0, colors='yellow')

        # Plot the door line and the roof line
        pl.hlines([self.door_line, self.sky_line], self.facade_left, self.facade_right, linestyles='dashed',
                  colors='yellow')

        self.window_grid.plot()
项目:facade-segmentation    作者:jfemiani    | 项目源码 | 文件源码
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)
项目:yt    作者:yt-project    | 项目源码 | 文件源码
def plot_channel(image, name, cmap='gist_heat', log=True, dex=3, zero_factor=1.0e-10, 
                 label=None, label_color='w', label_size='large'):
    """
    This function will plot a single channel. *image* is an array shaped like
    (N,M), *name* is the pefix for the output filename.  *cmap* is the name of
    the colormap to apply, *log* is whether or not the channel should be
    logged.  Additionally, you may optionally specify the minimum-value cutoff
    for scaling as *dex*, which is taken with respect to the minimum value of
    the image.  *zero_factor* applies a minimum value to all zero-valued
    elements.  Optionally, *label*, *label_color* and *label_size* may be
    specified.
    """
    import matplotlib
    import pylab
    Nvec = image.shape[0]
    image[np.isnan(image)] = 0.0
    ma = image[image>0.0].max()
    image[image==0.0] = ma*zero_factor
    if log:
        mynorm = matplotlib.colors.LogNorm(ma/(10.**dex), ma)

    pylab.clf()
    pylab.gcf().set_dpi(100)
    pylab.gcf().set_size_inches((Nvec/100.0, Nvec/100.0))
    pylab.gcf().subplots_adjust(left=0.0, right=1.0, bottom=0.0, top=1.0, wspace=0.0, hspace=0.0)
    mycm = pylab.cm.get_cmap(cmap)
    if log:
        pylab.imshow(image,cmap=mycm, norm=mynorm, interpolation='nearest')
    else:
        pylab.imshow(image,cmap=mycm, interpolation='nearest')
    if label is not None:
        pylab.text(20, 20,label, color = label_color, size=label_size) 
    pylab.savefig("%s_%s.png" % (name,cmap))
    pylab.clf()
项目:BRATS    作者:ahmedhussein622    | 项目源码 | 文件源码
def show_image(img, strg = ""):
    plt.imshow(img, cmap = "Greys_r")
    plt.text(0, 0, strg, color = "r")
    plt.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show_results_prepare(self):
        font = {'family': 'serif',
                'color':  'k',
                'weight': 'normal',
                'size': 13,
        }
        pl.figure(1)
        pl.title('The Trajectory of Cannon Shells', fontdict = font)
        pl.xlabel('x / $km$')
        pl.ylabel('y / $km$')
        pl.xlim(0, 60)
        pl.ylim(0, 20)
        pl.grid(True)
        pl.text(2, 16.5, 'With air drag, the reduced air density \n        and g varying with altitudes', fontdict = font)
        pl.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def show(self):
        pl.plot(self.t, self.theta, label = '$F_D =$' + str(self.F_D))
        pl.xlim(0, 100)
        pl.ylim(-4, 4)
        pl.xlabel('time ($s$)')
        pl.ylabel('$\\theta$ (radians)')
        pl.legend()
#        pl.text(32, 2, '$\\theta$ versus time $F_D =$' + str(self.F_D))

#pl.subplot(311)
#r1 = routes_to_chaos(amplitude = 1.35)
#r1.calculate()
#r1.show()
#pl.subplot(312)
#r2 = routes_to_chaos(amplitude = 1.44)
#r2.calculate()
#r2.show()
#pl.subplot(313)
#r3 = routes_to_chaos(amplitude = 1.465)
#r3.calculate()
#r3.show()
#pl.show()

#r= routes_to_chaos(amplitude = 1.465)
#r.calculate()
#r.show()
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.t,self.theta, 'c')
        pl.ylim(-4, 4)
        pl.xlim(0, 8)
        pl.ylabel('$\\theta$ (radians)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\theta$ versus time')
        pl.text(3.3, 3.5, 'Circular orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot_delta(self):
        pl.figure(figsize = (8, 8))
        pl.semilogy(self.tprime, self.deltatheta, 'r')
#        pl.ylim(0.0001, 0.1)
#        pl.ylim(0.0001, 10)
        pl.xlim(0, 100)
        pl.ylabel('$\\Delta\\theta$ (radians)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\theta$ versus time')
        pl.text(4.1, 3e3, 'Ellipitical orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.theta,self.omega, 'k.')
#        pl.ylim(-4, 4)
#        pl.xlim(0, 8)
        pl.ylabel('$\\omega$ (radians/yr)')
        pl.xlabel('$\\theta$ (radians)')
        pl.title('Hyperion $\\omega$ versus $\\theta$')
        pl.text(-0.7, 13.3, 'Circular orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.theta,self.omega, 'k.')
#        pl.ylim(-4, 4)
#        pl.xlim(0, 8)
        pl.ylabel('$\\omega$ (radians/yr)')
        pl.xlabel('$\\theta$ (radians)')
        pl.title('Hyperion $\\omega$ versus $\\theta$')
        pl.text(-0.75, 56, 'Elliptical orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot_delta(self):
        pl.figure(figsize = (8, 8))
        pl.semilogy(self.tprime, self.deltatheta, 'r.')
#        pl.ylim(0.0001, 0.1)
        pl.ylim(0.0001, 10)
        pl.xlim(0, 10)
        pl.ylabel('$\\Delta\\theta$ (radians)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\theta$ versus time')
        pl.text(4.1, 2e-4, 'Ellipitical orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot_delta(self):
        pl.figure(figsize = (8, 8))
        pl.semilogy(self.tprime, self.deltatheta, 'r')
#        pl.ylim(0.0001, 0.1)
#        pl.ylim(0.0001, 0.1)
        pl.xlim(0, 100)
        pl.ylabel('$\\Delta\\theta$ (radians)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\theta$ versus time')
        pl.text(4.1, 0.05, 'Circular orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.t,self.omega, 'c')
        pl.ylim(-20, 60)
        pl.xlim(0, 10)
        pl.ylabel('$\\omega$ (radians/yr)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\omega$ versus time')
        pl.text(4.1, 55, 'Elliptical orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.t,self.theta)
        pl.plot(self.t,self.theta, 'c')
        pl.ylim(-4, 4)
        pl.xlim(0, 10)
        pl.ylabel('$\\theta$ (radians)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\theta$ versus time')
        pl.text(4.1, 3.5, 'Elliptical orbit')
项目:computational_physics_N2014301020117    作者:yukangnineteen    | 项目源码 | 文件源码
def plot(self):
        pl.figure(figsize = (8, 8))
        pl.plot(self.t,self.omega, 'c')
        pl.ylim(0, 15)
        pl.xlim(0, 8)
        pl.ylabel('$\\omega$ (radians/yr)')
        pl.xlabel('time (yr)')
        pl.title('Hyperion $\\omega$ versus time')
        pl.text(3.3, 13.5, 'Circular orbit')
项目:autoxd    作者:nessessary    | 项目源码 | 文件源码
def DrawStr(s):
    pl.figure
    pl.text(0,0,s)
    pl.show()
    pl.close()
项目:autoxd    作者:nessessary    | 项目源码 | 文件源码
def text(x, y, s, fontdict=None, withdash=False, **kwargs):
        pl.text(x, y, s, fontdict, withdash, **kwargs)
项目: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'))
项目: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)
项目:ngas    作者:ICRAR    | 项目源码 | 文件源码
def plot(self, output=None):
        """
        Plot the statistics.

        INPUT: None
        OUTPUT: None

        SIDE EFFECTS: Generates a plot, depending on the output mode of pylab
             this may open a ne window.
        """
        fig = pylab.figure()

        ax1 = fig.add_subplot(111)
        ax1.set_xlabel(self.mode[1])
        ax1.set_ylabel('MB/s')
        ax1.set_xlim([0,self.loop+0.5])
        ax1.bar(where(self.y>=0)[0]+0.1,self.y)
        ax1.xaxis.axes.set_autoscalex_on(False)
        ax1.plot([0,self.loop+0.5],[median(self.y[where(self.y > 0)]),
                                    median(self.y[where(self.y > 0)])])
        ax1.plot([0,self.loop+0.5],[mean(self.y[where(self.y > 0)]),
                                    mean(self.y[where(self.y > 0)])])

        pylab.text(0.02,0.95,'Median: %5.2f MB/s'
                   % median(self.y[where(self.y > 0)]),
                   transform = ax1.transAxes,ha='left', va='bottom', color='b',
                   fontsize=10)
        pylab.text(0.02,0.95,'Mean: %5.2f MB/s'
                   % mean(self.y[where(self.y > 0)]),
                   transform = ax1.transAxes,ha='left', va='top', color='g',
                   fontsize=10)

        ax2 = ax1.twinx()
        ax2.xaxis.axes.set_autoscalex_on(False)
        ax2.plot(where(self.n>=0)[0]+0.5,self.n,'r-', marker='o')

        for tl in ax2.get_yticklabels():
            tl.set_color('r')
        ax2.set_ylabel('Number of files',{'color':'r'})

        if self.mode[1] == 'Day':
            fig.canvas.set_window_title('%s: %s' % (self.db,self.date))
            ax2.set_title('%s %s ingest rate: %s' % (self.db, self.mode[0], self.date))
        else:
            fig.canvas.set_window_title('%s: %s' % (self.db,self.date))
            ax2.set_title('%s %s ingest rate: %s' % (self.db, self.mode[0], self.date))

        pylab.text(0.99,0.95,'Total: %5.2f TB' % self.tvol,transform = ax1.transAxes,ha='right', va='bottom')
        pylab.text(0.99,0.95,'Total # files: %8d' % self.tfils,transform = ax1.transAxes,ha='right', va='top')

        if (output is not None):
            fig.savefig(output)
        else:
            fig.show()
        #pl.close(fig)
项目:BRATS    作者:ahmedhussein622    | 项目源码 | 文件源码
def fast_load(self, file_name):
        file_name = file_name + "_extra"
        with open(file_name, 'rb') as f:
            (self.current_run, self.current_patient, self.patients[self.current_patient].current_voxel) =  pickle.load(f)



# Patient.find_patients()
# b = Batch_balanced(Patient.patients_list[0:10], 17)
# b.start_iteration()
# 
# k = 10000
# (X, y) = b.get_batch(k, two_class=True)
# b.stop_iteration()
# 
# 
# print("done ")
# print(X.shape)
# print(y.shape)
# 
# for i in range(0, k):
#     plt.imshow(X[i][0], cmap = "Greys_r")
#     plt.text(0, 0, "class : "+str(y[i]), color = "r")
#     plt.show()


# 
# b.set_current_location(1, 140, 0, 0)
# 
# b.start_iteration()
# 
# 
# print(b.get_current_location())
# print(b.has_next_batch())
# x, y = b.get_batch(10000000)
# print(x.shape)


# print(b.patients[b.current_patient].get_current_input())
# print(b.patients[b.current_patient].get_current_location())
# print(b.get_current_location())
# print(b.has_next_batch())
# 
# b.stop_iteration()
项目:breaking_cycles_in_noisy_hierarchies    作者:zhenv5    | 项目源码 | 文件源码
def plotPrecisionRecallDiagram(title="title", points=None, labels=None, loc="best",xy_ranges = [0.6, 1.0, 0.6, 1.0], save_file = None):
    """Plot (precision,recall) values with 10 f-Measure equipotential lines.

    Plots into the current canvas.
    Points is a list of (precision,recall) pairs.
    Optionally you can also provide labels (list of strings), which will be
    used to create a legend, which is located at loc.
    """
    if labels:
        ax = pl.axes([0.1, 0.1, 0.7, 0.8])  # llc_x, llc_y, width, height
    else:
        ax = pl.gca()
    pl.title(title)
    pl.xlabel("Precision")
    pl.ylabel("Recall")
    _plotFMeasures(start = min(xy_ranges[0],xy_ranges[2]), end = max(xy_ranges[1],xy_ranges[3]))

    if points:
        getColor = it.cycle(colors).next
        getMarker = it.cycle(markers).next

        scps = []  # scatter points
        for i, (x, y) in enumerate(points):
            label = None
            if labels:
                label = labels[i]
            print i, x, y, label
            scp = ax.scatter(x, y, label=label, s=50, linewidths=0.75,
                             facecolor=getColor(), alpha=0.75, marker=getMarker())
            scps.append(scp)
            # pl.plot(x,y, label=label, marker=getMarker(), markeredgewidth=0.75, markerfacecolor=getColor())
            # if labels: pl.text(x, y, label, fontsize="x-small")
        if labels:
            # pl.legend(scps, labels, loc=loc, scatterpoints=1, numpoints=1, fancybox=True) # passing scps & labels explicitly to work around a bug with legend seeming to miss out the 2nd scatterplot
            #pl.legend(scps, labels, loc=(1.01, 0), scatterpoints=1, numpoints=1, fancybox=True)  # passing scps & labels explicitly to work around a bug with legend seeming to miss out the 2nd scatterplot
            pl.legend(scps, labels, loc= loc, scatterpoints=1, numpoints=1, fancybox=True,fontsize = 10)  # passing scps & labels explicitly to work around a bug with legend seeming to miss out the 2nd scatterplot
    pl.axis(xy_ranges)  # xmin, xmax, ymin, ymax
    if save_file:
        pl.savefig(save_file)

    pl.show()
    pl.close()
项目: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()
项目:ugali    作者:DarkEnergySurvey    | 项目源码 | 文件源码
def plotTriangle(srcfile,samples,burn=0,**kwargs):
    #import triangle
    import corner
    import ugali.analysis.source
    import ugali.analysis.mcmc
    #matplotlib.rcParams.update({'text.usetex': True})

    source = ugali.analysis.source.Source()
    source.load(srcfile,section='source')
    params = source.get_params()
    results = yaml.load(open(srcfile))['results']
    samples = ugali.analysis.mcmc.Samples(samples)

    names = samples.names
    labels = names 
    truths = [params[n] for n in names]
    chain = samples.get(burn=burn,clip=5)

    ### Triangle plot
    #extents = [[0,15e3],[323.6,323.8],[-59.8,-59.7],[0,0.1],[19.5,20.5]]

    kwargs.setdefault('extents',None)
    kwargs.setdefault('plot_contours',True)
    kwargs.setdefault('plot_datapoints',True)
    kwargs.setdefault('verbose',False)
    kwargs.setdefault('quantiles',[0.16,0.84])

    if len(names) > 1:
        fig = corner.corner(chain,labels=labels,truths=truths,**kwargs)
    else:
        fig = plt.figure()
        plt.hist(chain,bins=100)
        plt.xlabel(names[0])

    try:
        text  = 'RA,DEC = (%.2f,%.2f)\n'%(results['ra'][0],results['dec'][0])
        text += '(m-M,D) = (%.1f, %.0f kpc)\n'%(results['distance_modulus'][0],results['distance'][0])
        text += r'$r_h$ = %.1f arcmin'%(results['extension_arcmin'][0])+'\n'
        text += 'TS = %.1f\n'%results['ts'][0]
        text += 'NSamples = %i\n'%(len(chain))
        #plt.figtext(0.65,0.90,text,ha='left',va='top')
    except KeyError as e:
        logger.warning(str(e))
        pass

    label = map(str.capitalize,source.name.split('_'))
    label[-1] = label[-1].upper()
    title = '%s'%' '.join(label)
    plt.suptitle(title)


############################################################