当前位置: 首页>>代码示例>>Python>>正文


Python pylab.gca函数代码示例

本文整理汇总了Python中pylab.gca函数的典型用法代码示例。如果您正苦于以下问题:Python gca函数的具体用法?Python gca怎么用?Python gca使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了gca函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: plotBode

def plotBode(fAg, lowerFreq, higherFreq = None):
    """'  plot Bode diagram using matplotlib
        Default frequency width is 3 decades
    '"""
    import pylab as py
    #import pdb; pdb.set_trace()
    if ( higherFreq == None):
        rangeAt = 1000.0  # 3 decade
    else:
        assert higherFreq > lowerFreq
        rangeAt = float(higherFreq)/lowerFreq

    N = 128
    lstScannAngFreqAt = [2*sc.pi*1j*lowerFreq*sc.exp(
                                                sc.log(rangeAt)*float(k)/N)
                                for k in range(N)]

    t              = [        lowerFreq*sc.exp(sc.log(rangeAt)*float(k)/N)
                                for k in range(N)]

    py.subplot(211)
    py.loglog( t, [(abs(fAg(x))) for x in lstScannAngFreqAt]  )
    py.ylabel('gain')
    py.grid(True)

    py.subplot(212)
    py.semilogx( t, [sc.arctan2(fAg(zz).imag, fAg(zz).real)
                        for zz in lstScannAngFreqAt])
    py.ylabel('phase')
    py.grid(True)
    py.gca().xaxis.grid(True, which='minor')  # minor grid on too
    py.show()
开发者ID:lobosKobayashi,项目名称:PythonSfCp932,代码行数:32,代码来源:rationalOp.py

示例2: test_set_plot_limits

 def test_set_plot_limits(self):
     """set_limits() properly sets limits
     """
     args = MagicMock(savefig="", xlim=[-2, 2], ylim=[-3, 3])
     plot_lib.set_limits(args)
     self.assertEqual(pl.gca().get_xlim(), (-2.0, 2.0))
     self.assertEqual(pl.gca().get_ylim(), (-3.0, 3.0))
开发者ID:richwu,项目名称:pandashells,代码行数:7,代码来源:plot_lib_tests.py

示例3: trace

def trace(data, name, format='png', datarange=(None, None), suffix='', path='./', rows=1, columns=1, 
    num=1, last=True, fontmap = None, verbose=1):
    """
    Generates trace plot from an array of data.

    :Arguments:
        data: array or list
            Usually a trace from an MCMC sample.

        name: string
            The name of the trace.
            
        datarange: tuple or list
            Preferred y-range of trace (defaults to (None,None)).

        format (optional): string
            Graphic output format (defaults to png).

        suffix (optional): string
            Filename suffix.

        path (optional): string
            Specifies location for saving plots (defaults to local directory).
            
        fontmap (optional): dict
            Font map for plot.

    """

    if fontmap is None: fontmap = {1:10, 2:8, 3:6, 4:5, 5:4}

    # Stand-alone plot or subplot?
    standalone = rows==1 and columns==1 and num==1

    if standalone:
        if verbose>0:
            print_('Plotting', name)
        figure()

    subplot(rows, columns, num)
    pyplot(data.tolist())
    ylim(datarange)

    # Plot options
    title('\n\n   %s trace'%name, x=0., y=1., ha='left', va='top', fontsize='small')

    # Smaller tick labels
    tlabels = gca().get_xticklabels()
    setp(tlabels, 'fontsize', fontmap[rows/2])

    tlabels = gca().get_yticklabels()
    setp(tlabels, 'fontsize', fontmap[rows/2])

    if standalone:
        if not os.path.exists(path):
            os.mkdir(path)
        if not path.endswith('/'):
            path += '/'
        # Save to file
        savefig("%s%s%s.%s" % (path, name, suffix, format))
开发者ID:CosmologyTaskForce,项目名称:pymc,代码行数:60,代码来源:Matplot.py

示例4: plot_file_color

def plot_file_color(base, thin=True, start=0, size=14, save=False):
    conf, track, pegs = load(base)

    fig = pl.figure(figsize=(size,size*conf['top']/conf['wall']))

    track = track[start:]
    x = track[:,0];   y = track[:,1]
    t = np.linspace(0,1,x.shape[0])
    points = np.array([x,y]).transpose().reshape(-1,1,2)
    segs = np.concatenate([points[:-1],points[1:]],axis=1)
    lc = LineCollection(segs, linewidths=0.25, cmap=pl.cm.coolwarm)
    lc.set_array(t)
    pl.gca().add_collection(lc)

    #pl.scatter(x, y, c=np.arange(len(x)),linestyle='-',cmap=pl.cm.coolwarm)
    #pl.plot(track[-1000000:,0], track[-1000000:,1], '-', linewidth=0.0125, alpha=0.8)
    for peg in pegs:
        pl.gca().add_artist(pl.Circle(peg, conf['radius'], color='k', alpha=0.3))
    pl.xlim(0, conf['wall'])
    pl.ylim(0, conf['top'])
    pl.xticks([])
    pl.yticks([])
    pl.tight_layout()
    pl.show()
    if save:
        pl.savefig(base+".png", dpi=200)
开发者ID:mattbierbaum,项目名称:plinko,代码行数:26,代码来源:plotting.py

示例5: show_image

def show_image(*imgs): 
    for idx, img in enumerate(imgs):
        subplot = 101 + len(imgs)*10 +idx
        pl.subplot(subplot)
        pl.imshow(img, cmap=pl.cm.gray)   
        pl.gca().set_axis_off()    
    pl.subplots_adjust(0.02, 0, 0.98, 1, 0.02, 0)        
开发者ID:shark803,项目名称:PythonCodeFromBook,代码行数:7,代码来源:binary_image_common.py

示例6: _plotResults

def _plotResults(naDist1, naDist2, lfOneKnn, lf5Knn):
    plt.clf()

    plt.subplot(311)
    plt.scatter(naDist1[:, 0], naDist1[:, 1])

    plt.scatter(naDist2[:, 0], naDist2[:, 1], color="r")

    # plt.ylabel( 'Feature 2' )
    # plt.xlabel( 'Feature 1' )
    # gca().annotate( '', xy=( .8, 0 ), xytext=( -.3 , 0 ), arrowprops=dict(facecolor='red', shrink=0.05) )
    gca().annotate("", xy=(0.7, 0), xytext=(1.5, 0), arrowprops=dict(facecolor="black", shrink=0.05))
    plt.title("Data Distribution")

    plt.subplot(312)

    plt.plot(range(len(lfOneKnn)), lfOneKnn)

    plt.ylabel("1-KNN Value")
    # plt.xlabel( 'Distribution Merge' )

    plt.title("1-KNN Performance")

    plt.subplot(313)

    plt.plot(range(len(lf5Knn)), lf5Knn)

    plt.ylabel("% Correct Classification")
    # plt.xlabel( 'Distribution Merge' )

    plt.title("5-KNN Performance")

    plt.subplots_adjust()

    plt.show()
开发者ID:hughdbrown,项目名称:QSTK,代码行数:35,代码来源:1knn.py

示例7: auto_shift

def auto_shift(offset):
    """
    Return a y-offset coordinate transform for the current axes.

    Each call to auto_shift increases the y-offset for the next line by
    the given number of points (with 72 points per inch).

    Example::

        from matplotlib import pyplot as plt
        from bumps.plotutil import auto_shift
        trans = auto_shift(plt.gca())
        plot(x, y, hold=True, trans=trans)
    """
    from matplotlib.transforms import ScaledTranslation
    import pylab
    ax = pylab.gca()
    if ax.lines and hasattr(ax, '_auto_shift'):
        ax._auto_shift += offset
    else:
        ax._auto_shift = 0
    trans = pylab.gca().transData
    if ax._auto_shift:
        trans += ScaledTranslation(0, ax._auto_shift/72.,
                                   pylab.gcf().dpi_scale_trans)
    return trans
开发者ID:richardsheridan,项目名称:bumps,代码行数:26,代码来源:plotutil.py

示例8: plotNumVariants

def plotNumVariants(depth):
    plt.figure(figsize=(7, 5), dpi=300)
    depth.apply(lambda x: x.dropna().size / 1000.0).unstack("POP").plot.bar(ax=plt.gca())
    plt.gcf().subplots_adjust(bottom=0.30)
    plt.ylabel(r"Num of variants ($\times$1000)")
    renameLegend(ax=plt.gca())
    plt.savefig(pathPlots + "numVariants.pdf")
开发者ID:airanmehr,项目名称:bio,代码行数:7,代码来源:Utils.py

示例9: plot

def plot(filename):
    """
    Read and print all command line arguments
    """
    import pylab

    canvas = pylab.gcf().canvas
    d = data(filename)
    if len(d.v.shape) > 2:
        pylab.gca().pcolormesh(d.v[0, :, :])
        pylab.xlabel(d.xlabel)
        pylab.ylabel(d.ylabel)
    elif len(d.v.shape) > 1:
        if filename.lower().endswith('bt4'):
            offset = 1
        else:
            offset = 0
        pylab.gca().pcolorfast(d.v[:, offset:])
        pylab.xlabel(d.xlabel)
        pylab.ylabel(d.ylabel)
    else:
        pylab.plot(d.x, d.v)
        pylab.xlabel(d.xlabel)
        pylab.ylabel(d.vlabel)
    pylab.show()
开发者ID:scattering,项目名称:dataflow,代码行数:25,代码来源:icpformat.py

示例10: _show_rates

def _show_rates(rate, wo, wt, attenuator, tau_NP, tau_P):
    import pylab

    #pylab.figure()
    pylab.errorbar(rate, wt[0], yerr=wt[1], fmt='g.', label='attenuated')
    pylab.errorbar(rate, wo[0], yerr=wo[1], fmt='b.', label='unattenuated')

    pylab.xscale('log')
    pylab.yscale('log')
    pylab.xlabel('incident rate (counts/second)')
    pylab.ylabel('observed rate (counts/second)')
    pylab.legend(loc='best')
    pylab.grid(True)
    pylab.plot(rate, rate/attenuator, 'g-', label='target')
    pylab.plot(rate, rate, 'b-', label='target')

    Ipeak, Rpeak = peak_rate(tau_NP=tau_NP, tau_P=tau_P)
    if rate[0] <= Ipeak <= rate[-1]:
        pylab.axvline(x=Ipeak, ls='--', c='b')
        pylab.text(x=Ipeak, y=0.05, s=' %g'%Ipeak,
                   ha='left', va='bottom',
                   transform=pylab.gca().get_xaxis_transform())
    if False:
        pylab.axhline(y=Rpeak, ls='--', c='b')
        pylab.text(y=Rpeak, x=0.05, s=' %g\n'%Rpeak,
                   ha='left', va='bottom',
                   transform=pylab.gca().get_yaxis_transform())
开发者ID:reflectometry,项目名称:reduction,代码行数:27,代码来源:deadtime_fit.py

示例11: learning_curve_plot

def learning_curve_plot(
    predictors, valid_X, valid_Y, valid_W=None, train_X=None, train_Y=None, train_W=None, log_scale=False
):

    if hasattr(valid_W, "values"):
        valid_W = valid_W.values
    if train_W != None and hasattr(train_W, "values"):
        train_W = weights.values

    with_train = True if (train_X != None and valid_X != None) else False

    try:
        predictors = predictors.items()
    except:
        predictors = {"": predictors}.items()

    for name, predictor in predictors:
        iterations = np.arange(1, predictor.n_estimators + 1)
        p, = plt.plot(
            iterations, _step_wise_performance(predictor, valid_X, valid_Y, valid_W), "-", label=name + " (test)"
        )

        if with_train:
            plt.plot(
                iterations,
                _step_wise_performance(predictor, train_X, train_Y, train_W),
                "--",
                color=p.get_color(),
                label=name + " (train)",
            )

        plt.legend(loc="best")

    if log_scale:
        plt.gca().set_xscale("log")
开发者ID:DjalelBBZ,项目名称:SOS14_practical_session,代码行数:35,代码来源:SOS_tools.py

示例12: plot

def plot(D,title):
    im=plt.imshow(D,interpolation='nearest',cmap='Reds')
    plt.gca().xaxis.tick_top()
    x=np.arange(D.index.shape[0])
    plt.colorbar(im)
    plt.gca().tick_params(axis='both', which='major', labelsize=10)
    plt.title(title,y=1.03)
开发者ID:airanmehr,项目名称:bio,代码行数:7,代码来源:Assigment2.py

示例13: plot_INT_footprint

def plot_INT_footprint(center_ra,center_dec):
    #using full detector sizes for now because 
    detector_dra = 4100.*0.33/3600. # 2154 pixels * 0.33"/pix, /3600 to get deg
    detector_ddec = 2048.*0.33/3600. # 2154 pixels * 0.33"/pix, /3600 to get deg
    # draw footprint of chip 4
    rect= plt.Rectangle((center_ra-detector_dra/2.,center_dec-detector_ddec/2.), detector_dra, detector_ddec,fill=False, color='k')
    plt.gca().add_artist(rect)
    # draw footprint of chip 3
    # assuming chip 3 is NORTH and a smidge WEST of chip 4
    offset_dec = detector_ddec+17./3600. # 17 arcsec gap in RA between 
    offset_ra = -9.5/3600. # 9.5 arcsec offset toward N
    rect= plt.Rectangle((center_ra+offset_ra-detector_dra/2.,center_dec+offset_dec-detector_ddec/2.), detector_dra, detector_ddec,fill=False, color='k')
    plt.gca().add_artist(rect)

    # draw footprint of chip 1
    # assuming chip 1 is SOUTH and a smidge EAST of chip 4
    offset_dec = -1*detector_ddec-22.7/3600. # 17 arcsec gap in RA between 
    offset_ra = +3.18/3600. # 9.5 arcsec offset toward N
    rect= plt.Rectangle((center_ra+offset_ra-detector_dra/2.,center_dec+offset_dec-detector_ddec/2.), detector_dra, detector_ddec,fill=False, color='k')
    plt.gca().add_artist(rect)

    # draw footprint of chip 2
    # assuming chip 2 is WEST of chip 4
    offset_dec = detector_ddec/2.-detector_dra-19.2/3600. # hard to explain
    offset_ra =  -.5*detector_dra-23.8/3600.# hard to explain
    # this chip is rotated 90 deg, so detecter_dra and detector_ddec are interchanged
    rect= plt.Rectangle((center_ra+offset_ra,center_dec+offset_dec), -1.*detector_ddec, detector_dra,fill=False, color='k')
    plt.gca().add_artist(rect)

    # adding guide camera
    offset_dec = -2*detector_ddec-(22.7+98.1)/3600. # hard to explain
    offset_ra =  detector_dra/2-(3.18+649.9)/3600.# hard to explain
    # this chip is rotated 90 deg, so detecter_dra and detector_ddec are interchanged
    rect= plt.Rectangle((center_ra+offset_ra,center_dec+offset_dec), -7./60., 7./60,fill=False, color='k')
    plt.gca().add_artist(rect)
开发者ID:rfinn,项目名称:Virgo,代码行数:35,代码来源:kpno-halpha.p3.py

示例14: validate_vs_jwpsf_nircam

def validate_vs_jwpsf_nircam():

    models = [ ('NIRCam','F200W', 'f200w_perfect_offset', '/Users/mperrin/software/jwpsf_v3.0/data/NIRCam/OPD/perfect_opd.fits', 0.034,True),
            ('NIRCam','F200W', 'f200w_perfect', '/Users/mperrin/software/jwpsf_v3.0/data/NIRCam/OPD/perfect_opd.fits', 0.034,False),
            ('NIRCam','F200W', 'f200w', '/Users/mperrin/software/jwpsf_v3.0/data/NIRCam/OPD/nircam_obs_w_rsrv1.fits', 0.034,True),
                ('MIRI','F1000W', 'f1000w', '/Users/mperrin/software/jwpsf_v3.0/data/MIRI/OPD/MIRI_OPDisim1.fits', 0.11,True)]


    fig = P.figure(1, figsize=(13,8.5), dpi=80)
    oversamp=4
    for params in models:

        nc = webbpsf_core.Instrument(params[0])
        nc.filter = params[1]
        nc.pupilopd = params[3] #'/Users/mperrin/software/jwpsf_v3.0/data/NIRCam/OPD/nircam_obs_w_rsrv1.fits'
        nc.pixelscale = params[4] #0.034 # this is wrong, but compute this way to match JWPSF exactly
        if params[5]:
            # offset by half a pixel to match the JWPSF convention
            nc.options['source_offset_r'] = params[4]/2 * N.sqrt(2)/oversamp  # offset half a pixel each in X and Y
            nc.options['source_offset_theta'] = -45


        jw_fn = 'jwpsf_%s_%s.fits' % (params[0].lower(), params[2].lower())
        my_fn = 'test_vs_' + jw_fn

        if not os.path.exists( my_fn):
            my_psf = nc.calcPSF(my_fn, oversample=oversamp, fov_pixels=512./oversamp)
        else:
            my_psf = fits.open(my_fn)

        jw_psf = fits.open(jw_fn)
        jw_psf[0].header.update('PIXELSCL', jw_psf[0].header['CDELT1']*3600)


        P.clf()
        #P.subplots_adjust(top=0.95, bottom=0.05, left=0.01, right=0.99)
        P.subplot(231)
        titlestr = "%s %s, \n"%  (params[0], params[2])
        poppy.display_PSF(my_psf, title=titlestr+"computed with WebbPSF" , colorbar=False)
        P.subplot(232)
        poppy.display_PSF(jw_psf, title=titlestr+"computed with JWPSF" , colorbar=False)
        P.subplot(233)
        poppy.display_PSF_difference(my_psf,jw_psf, title=titlestr+'Difference Image', colorbar=False)

        imagecrop = 30*params[4]

        P.subplot(234)
        poppy.display_PSF(my_psf, title=titlestr+"computed with WebbPSF", colorbar=False, imagecrop=imagecrop)
        centroid = poppy.measure_centroid(my_psf)
        P.gca().set_xlabel("centroid = (%.3f,%.3f)" % centroid)

        P.subplot(235)
        poppy.display_PSF(jw_psf, title=titlestr+"computed with JWPSF", colorbar=False, imagecrop=imagecrop)
        centroid = poppy.measure_centroid(jw_psf)
        P.gca().set_xlabel("centroid = (%.3f,%.3f)" % centroid)

        P.subplot(236)
        poppy.display_PSF_difference(my_psf,jw_psf, title='Difference Image', colorbar=False, imagecrop=imagecrop)

        P.savefig("results_vs_jwpsf_%s_%s.pdf" % (params[0], params[2]))
开发者ID:tepickering,项目名称:webbpsf,代码行数:60,代码来源:validate_vs_jwpsf.py

示例15: plot_descur

def plot_descur(RBC, RBS, ZBC, ZBS, max_m, max_n, phi_plane=0., nu=150, debug=1, **plkwargs):
    """ Companion plotting routine to read_descur_data
    """
    theta_arr = linspace(0,2*pi,nu,endpoint=True)
    r_c = 0*theta_arr
    z_c = 0*theta_arr
    r_c2 = 0*theta_arr
    z_c2 = 0*theta_arr
    for (i,theta) in enumerate(theta_arr):
        for ixm in range(0, max_m):
            if ixm==0: start_n=0
            else: start_n = -max_n
            for ixn in range(start_n, 1+max_n):
                arg = ixn*phi_plane + ixm*theta
                sinarg = sin(arg)
                cosarg = cos(arg)
                r_c[i] += (RBC[ixn,ixm]*cosarg) + (RBS[ixn,ixm]*sinarg)
                z_c[i] += (ZBC[ixn,ixm]*cosarg) + (ZBS[ixn,ixm]*sinarg)
                r_c2[i] += (RBC[ixn,ixm]*cosarg) #Shaun modification to show the stellarator symetric version
                z_c2[i] += (ZBS[ixn,ixm]*sinarg) #Shaun modification to show the stellarator symetric version

    pl.plot(r_c, z_c, **plkwargs)
    pl.plot(r_c2, z_c2, **plkwargs)
    pl.gca().set_aspect('equal')
    pl.show()
    if debug>3:
        import pdb; pdb.set_trace()
        'debugging, c to continue'
开发者ID:bernhardseiwald,项目名称:python-h1,代码行数:28,代码来源:heliac_vmec_utils.py


注:本文中的pylab.gca函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。