• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python cm.rainbow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: plotPoints3D

 def plotPoints3D(self): 
     colors = cm.rainbow(np.linspace(0, 1, self.cl_cnt))
     fig = plt.figure()
     ax = fig.add_subplot(111, projection='3d')
     
     for c in range(self.cl_cnt):
         centroid = self.centroids[c]
         x = []
         y = []
         z = []
         cluster_size = len(self.cl_points[c])
         
         #for each point assorted to the cluster
         for p in range(cluster_size):
             index = self.cl_points[c][p] #index of the point
             point = self.points[index]
             #print point
             x.append(point[0])
             y.append(point[1])
             z.append(point[2])
         
         clrs = cm.rainbow(np.linspace(0, 1, self.cl_cnt)) #colors
         
         ax.scatter(x, y, z, color=clrs[c], marker='o')
         ax.scatter(centroid[0], centroid[1], centroid[2],
                    color=clrs[c], marker='*', s = 50)
         ax.set_xlabel('X')
         ax.set_ylabel('Y')
         ax.set_zlabel('Z')
     
     plt.show()
开发者ID:Rihorama,项目名称:FME,代码行数:31,代码来源:KM_kmeans.py


示例2: LogScaleASP

def LogScaleASP(LRange, Data, unlogged = False, scale = False, tau = 0, D = 0, tauEst = 0, DEst = 0):
    """
    Plots log-binned avalanche size probabilities 
    (if logbin == True, also plots unprocessed data)
    """
    plt.figure()
    for d in range(len(Data)):
        colors = cm.rainbow(np.linspace(0, 1, len(Data)))
        if unlogged:
            plt.scatter(np.arange(0,len(Data[d][0])),Data[d][0],s = 0.5, label = 'Raw Data')
        for i in range(len(Data[d][1])):
            #plt.plot(Data[d][1][i][0],Data[d][1][i][1],color = colors[d],label = 'L = ' + str(LRange[d]))
            plt.plot(Data[d][1][i][0],Data[d][1][i][1],color = colors[d],label = 'Log-Binned Data')
            #plt.plot(np.arange(0,len(Data[d][1][i])),Data[d][1][i],color = colors[d])
    if tauEst != 0:
        #print 't'
        plt.plot([1,10**10],[1,(10**10)**(-tauEst)],linestyle = 'dashed',label = r'$P_N(s;L)\propto s^{-\tau_s}$')
    plt.xscale('log')
    plt.yscale('log')
    #ax = plt.axes()
    #ax.grid(True)
    plt.xlim((10**0,10**(round(math.log(len(Data[-1][0]),10)) + 1)))
    plt.ylim((10**(round(math.log(Data[-1][1][0][1][-1],10)) - 1), 10**0))
    plt.xlabel(r'$s$', fontsize = 20)
    plt.ylabel(r'$\tilde{P}_N(s;L)$', fontsize = 20)
    plt.title(r'$N = 10^9$',fontsize = 25)
    plt.legend(prop = {'size':25})
    #fig.savefig('Pvs.eps', format = 'eps', dpi = 1000)
    logp = [i[1][0] for i in Data]
    pscaled = [[p*math.pow(s,tau) for (p,s) in zip(logp[i][1],logp[i][0])] for i in range(len(logp))]
    sscaled = [[s/LRange[i]**D for s in logp[i][0]] for i in range(len(logp))]
    if scale:
        plt.figure()
        plt.xscale('log')
        plt.yscale('log')
        ax = plt.axes()
        ax.grid(True)
        #plt.xlim((10**0,10**(round(math.log(len(Data[-1][0]),10)) + 1)))
        #plt.ylim((10**(-2), 10**0))
        plt.ylabel(r'$s^{\tau_s}P(s;L)$',fontsize = 20)
        plt.xlabel(r'$s$', fontsize = 20)
        for d in range(len(Data)):
            colors = cm.rainbow(np.linspace(0, 1, len(Data)))
            plt.plot(logp[d][0],pscaled[d],color = colors[d],label = 'L =' + str(LRange[d]))
        plt.legend(prop = {'size':15},loc =3)
        plt.figure()
        ax = plt.axes()
        ax.grid(True)
        plt.xscale('log')
        plt.yscale('log')
        #plt.xlim((10**(-6),10**2))
        #plt.ylim((10**(-2), 10**0))
        plt.ylabel(r'$s^{\tau_s}P(s;L)$',fontsize = 20)
        plt.xlabel(r'$s/L^D$', fontsize = 20)
        for d in range(len(Data)):
            colors = cm.rainbow(np.linspace(0, 1, len(Data)))
            plt.plot(sscaled[d][1:],pscaled[d][1:],color = colors[d], label = 'L =' + str(LRange[d]))
        plt.legend(prop = {'size':15},loc = 3)
开发者ID:seblee97,项目名称:complexity,代码行数:58,代码来源:oslorun1.py


示例3: plot_epam_proton_lcurves

def plot_epam_proton_lcurves(t1, t2):
	
	#convert time to datetime format
	dt1 = datetime.datetime.strptime(t1, "%d-%b-%Y %H:%M")
	dt2 = datetime.datetime.strptime(t2, "%d-%b-%Y %H:%M")

	#set up figure
	nl = 3
	xc = 255/nl
	f, ax = plt.subplots(figsize=(8,4))
	
	#ACE EPAM protons
	epam_dates0, epam_lcurve = parse_epam_proton_range(t1, t2)
	mxepam = np.amax(epam_lcurve)

	l1 = ax.plot(epam_dates0, epam_lcurve[:,0], c = cm.rainbow(1 * xc + 1) ,label='EPAM 0.540 - 0.765 MeV')
	l2 = ax.plot(epam_dates0, epam_lcurve[:,1], c = cm.rainbow(3 * xc + 1) ,label='EPAM 0.765 - 1.22 MeV')
	l3 = ax.plot(epam_dates0, epam_lcurve[:,2], c = cm.rainbow(5 * xc + 1) ,label='EPAM 1.22 - 4.94 MeV')
		
	#format of tick labels
	hrsFmt = mdates.DateFormatter('%d')
	ax.xaxis.set_major_formatter(hrsFmt)
	ax.set_xlabel("Start Time "+t1+" (UTC)")
	ax.set_xlim([dt1, dt2])
	ymax = np.max([mxepam, mxepam])
	ax.set_ylim(top = ymax)
	ax.set_ylim(bottom = 1.e-4)

	#auto orientate the labels so they don't overlap
	#f.autofmt_xdate()

	#set yaxis log
	ax.set_yscale('log')

	#Axes labels
	ax.set_title("ACE EPAM Protons")
	ax.set_ylabel('H Intensity $\mathrm{(cm^{2}\,sr\,s\,MeV)^{-1}}$')

	#legend
	fontP = FontProperties()
	fontP.set_size('x-small')

	leg = ax.legend(loc='best', prop = fontP, fancybox=True )
	leg.get_frame().set_alpha(0.5)

	#month
	year = dt1.year
	month = dt1.month

	plt.show()
	
	return None
开发者ID:hbain,项目名称:SEP,代码行数:52,代码来源:protons_range_epam.py


示例4: _DrawEmpiricalCdf

def _DrawEmpiricalCdf(axis, results):
  colors = cm.rainbow(numpy.linspace(  # pylint: disable=no-member
      1, 0, len(results) + 1))
  for (commit, values), color in zip(results, colors):
    # Empirical distribution function.
    levels = numpy.linspace(0, 1, len(values) + 1)
    axis.step(sorted(values) + [max(values)], levels,
              label='%s (n=%d)' % (commit, len(values)), color=color)

    # Dots denoting the percentiles.
    axis.plot(numpy.percentile(values, tuple(p * 100 for p in _PERCENTILES)),
              _PERCENTILES, '.', color=color)

  axis.set_yticks(_PERCENTILES)

  # Vertical lines denoting the medians.
  values_per_commit = [values for _, values in results]
  medians = tuple(numpy.percentile(values, 50) for values in values_per_commit)
  axis.set_xticks(medians, minor=True)
  axis.grid(which='minor', axis='x', linestyle='--')

  # Axis labels and legend.
  #axis.set_xlabel(step.metric_name)
  axis.set_ylabel('Cumulative probability')
  axis.legend(loc='lower right')
开发者ID:catapult-project,项目名称:catapult,代码行数:25,代码来源:plot_bisect_results.py


示例5: hists

def hists(dgrp,dfs):
    "dgrp = MAIN,DC,EC,SC,MC"
    #set up some cosmetics
    colors = cm.rainbow(np.linspace(0,1,len(dfs)))
    labels = ['h10_%d'%i for i in range(len(dfs))]
    
    ncols=len(dgrp['COLS'])
    gs =''
    if ncols > 4: 
        gs = gridspec.GridSpec(2,4)
    else: 
        gs = gridspec.GridSpec(1,ncols)

    for icol in np.arange(ncols):
        ax=plt.subplot(gs[icol])
        col=dgrp['COLS'][icol]
        nbins=dgrp['NBINS'][icol]
        xmin=dgrp['XMIN'][icol]
        xmax=dgrp['XMAX'][icol]
        #print 'col=%s:nbins=%d:xmin=%d:xmax%d'%(col,nbins,xmin,xmax)
        ax.set_title(col)
        ax.set_xlabel(col)
        for c,l,df in zip(colors,labels,dfs):
            #print df[col]
            plt.hist(df[col],nbins,(xmin,xmax), histtype='step',color=c,label=l)
    plt.legend(loc=2,prop={'size':8})
开发者ID:arjun-trivedi,项目名称:ana2pi,代码行数:26,代码来源:anah10.py


示例6: compare_subcarrier_location

def compare_subcarrier_location(alpha, M, K, overlap, oversampling_factor):
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    goofy_ordering = False
    taps = gfdm_filter_taps('rrc', alpha, M, K, oversampling_factor)
    A0 = gfdm_modulation_matrix(taps, M, K, oversampling_factor, group_by_subcarrier=goofy_ordering)
    n = np.arange(M * K * oversampling_factor, dtype=np.complex)
    colors = iter(cm.rainbow(np.linspace(0, 1, K)))

    for k in range(K):
        color = next(colors)
        f = np.exp(1j * 2 * np.pi * (float(k) / (K * oversampling_factor)) * n)
        F = abs(np.fft.fft(f))
        fm = np.argmax(F) / M
        plt.plot(F, '-.', label=k, color=color)

        data = get_zero_f_data(k, K, M)

        x0 = gfdm_gr_modulator(data, 'rrc', alpha, M, K, overlap, compat_mode=goofy_ordering) * (2. / K)
        f0 = 1. * np.argmax(abs(np.fft.fft(x0))) / M
        plt.plot(abs(np.fft.fft(x0)), label='FFT' + str(k), color=color)

        xA = A0.dot(get_data_matrix(data, K, group_by_subcarrier=goofy_ordering).flatten()) * (1. / K)
        fA = np.argmax(abs(np.fft.fft(xA))) / M
        plt.plot(abs(np.fft.fft(xA)), '-', label='matrix' + str(k), color=color)
        print fm, fA, f0
    plt.legend()
    plt.show()
开发者ID:jdemel,项目名称:gr-gfdm,代码行数:28,代码来源:gfdm_modulation.py


示例7: sendTSNE

    def sendTSNE(self, people):
        d = self.getData()
        if d is None:
            return
        else:
            (X, y) = d

        X_pca = PCA(n_components=50).fit_transform(X, X)
        tsne = TSNE(n_components=2, init='random', random_state=0)
        X_r = tsne.fit_transform(X_pca)

        yVals = list(np.unique(y))
        colors = cm.rainbow(np.linspace(0, 1, len(yVals)))

        # print(yVals)

        plt.figure()
        for c, i in zip(colors, yVals):
            name = "Unknown" if i == -1 else people[i]
            plt.scatter(X_r[y == i, 0], X_r[y == i, 1], c=c, label=name)
            plt.legend()

        imgdata = StringIO.StringIO()
        plt.savefig(imgdata, format='png')
        imgdata.seek(0)

        content = 'data:image/png;base64,' + \
                  urllib.quote(base64.b64encode(imgdata.buf))
        msg = {
            "type": "TSNE_DATA",
            "content": content
        }
        self.sendMessage(json.dumps(msg))
开发者ID:ChengLunHu,项目名称:TensorFace,代码行数:33,代码来源:server.py


示例8: plot_xyt_rotate

def plot_xyt_rotate(s):
    xyts = np.fromfile(pdir + 'lcr/rotate.dat')
    xs = xyts[1::7][::s]
    ys = xyts[2::7][::s]
    ts = xyts[6::7][::s]
    ds = [1-((x/350)**2 + (y/350)**2)**0.5 for x,y in zip(xs,ys)]
    cs = cm.rainbow(ds)

    fig = plt.figure()
    ax = fig.gca(projection='3d')
    ax.scatter(xs, ys, ts, color=cs, cmap=cm.hsv)
    ax.set_xlim3d(0, 300)
    ax.set_ylim3d(0, 300)
    ax.set_zlim3d(0, 16000)
    ax.set_xlabel('area length (m)')
    ax.set_ylabel('area width (m)')
    ax.set_zlabel('time (min)')
    ax.set_xticks([0,100,200,300])
    ax.set_yticks([0,100,200,300])
    ax.set_zticks([0,4000,8000,12000,16000])
    ax.ticklabel_format(axis='z', style='sci', scilimits=(-2,2))

    ax.view_init(elev=13., azim=-70)
    ax.grid(True)
    plt.show()
开发者ID:ChenChuang,项目名称:CSNetSim,代码行数:25,代码来源:plot.py


示例9: plot_dispatch

    def plot_dispatch(bus_to_plot):
        # plotting: later as multiple pdf with pie-charts and topology?
        import numpy as np
        import matplotlib as mpl
        import matplotlib.cm as cm

        plot_data = renew_sources+transformers

        # data preparation
        x = np.arange(len(timesteps))
        y = []
        labels = []
        for c in plot_data:
            if bus_to_plot in c.results['out']:
                y.append(c.results['out'][bus_to_plot])
                labels.append(c.uid)

        # plotting
        fig, ax = plt.subplots()
        sp = ax.stackplot(x, y,
                          colors=cm.rainbow(np.linspace(0, 1, len(plot_data))))
        proxy = [mpl.patches.Rectangle((0, 0), 0, 0,
                                       facecolor=
                                       pol.get_facecolor()[0]) for pol in sp]
        ax.legend(proxy, labels)
        ax.grid()
        ax.set_xlabel('Timesteps in h')
        ax.set_ylabel('Power in MW')
        ax.set_title('Dispatch')
开发者ID:chris-fleischer,项目名称:oemof_base_pypower,代码行数:29,代码来源:example_app.py


示例10: plot_kin_all

def plot_kin_all(expt_dh,imsd_fhs):
    fig=plt.figure(figsize=(8,3))
    colors=cm.rainbow(np.linspace(0,1,len(imsd_fhs)))
    ylimmx=[]
    for i,imsd_fh in enumerate(imsd_fhs):
        imsd_flt_fh='%s.imsd_flt' % imsd_fh
        imsd_flt=pd.read_csv(imsd_flt_fh).set_index('lag time [s]')
        params_flt_fh='%s.params_flt' % imsd_fh
        params_flt=pd.read_csv(params_flt_fh)
        ax1=plt.subplot(131)
        ax1=plot_kin(imsd_flt,
                 params_flt.loc[:,['power law exponent','power law constant']],
                 ctime='lag $t$',
                 fit_eqn='power',
                 smp_ctrl=None,
                 ylabel='MSD ($\mu m^{2}$)',
                 color=colors[i],
                 ymargin=0.2,
                 ax1=ax1,
                 label=basename(imsd_flt_fh).split('_replicate', 1)[0].replace('_',' '),
                 plot_fh=None)
        ylimmx.append(np.max(imsd_flt.max()))
    ax1.set_ylim([0,np.max(ylimmx)])
    ax1.legend(bbox_to_anchor=[1,1,0,0],loc=2)
    fig.savefig('%s/plot_flt_%s.pdf' % (expt_dh,dirname(expt_dh)))
开发者ID:rraadd88,项目名称:htsimaging,代码行数:25,代码来源:fit_kin.py


示例11: _plot_proto_symbol_space

def _plot_proto_symbol_space(coordinates, target_names, name, args):
    # Reduce to 2D so that we can plot it.
    coordinates_2d = TSNE().fit_transform(coordinates)

    n_samples = coordinates_2d.shape[0]
    x = coordinates_2d[:, 0]
    y = coordinates_2d[:, 1]
    colors = cm.rainbow(np.linspace(0, 1, n_samples))

    fig = plt.figure(1)
    plt.clf()
    ax = fig.add_subplot(111)
    dots = []
    for idx in xrange(n_samples):
        dots.append(ax.plot(x[idx], y[idx], "o", c=colors[idx], markersize=15)[0])
        ax.annotate(target_names[idx],  xy=(x[idx], y[idx]))
    lgd = ax.legend(dots, target_names, ncol=4, numpoints=1, loc='upper center', bbox_to_anchor=(0.5,-0.1))
    ax.grid('on')

    if args.output_dir is not None:
        path = os.path.join(args.output_dir, name + '.pdf')
        print('Saved plot to file "%s"' % path)
        fig.savefig(path, bbox_extra_artists=(lgd,), bbox_inches='tight')
    else:
        plt.show()
开发者ID:caomw,项目名称:motion-classification,代码行数:25,代码来源:evaluate.py


示例12: pca_3d

def pca_3d(X, component1, component2, component3, class_indices, path, name, data_legend):
    C, y, Z = pca(X, class_indices)

    colors = cm.rainbow(np.linspace(0, 1, C))
    markers = ["o", "v", "8", "s", "p", "*", "h", "H", "+", "x", "D"]
    while True:
        if C <= len(markers):
            break
        markers += markers

    # Plot PCA of the data
    f = plt.figure(figsize=(15, 15))
    ax = f.add_subplot(111, projection='3d', axisbg='white')
    ax._axis3don = False

    for c in range(C):
        # select indices belonging to class c:
        class_mask = y.A.ravel() == c
        xs = Z[class_mask, component1 - 1]
        xs = xs.reshape(len(xs)).tolist()[0]
        ys = Z[class_mask, component2 - 1]
        ys = ys.reshape(len(ys)).tolist()[0]
        zs = Z[class_mask, component3 - 1]
        zs = zs.reshape(len(zs)).tolist()[0]
        ax.scatter(xs, ys, zs, s=20, c=colors[c], marker=markers[c])


    # plt.figtext(0.5, 0.93, 'PCA 3D', ha='center', color='black', weight='light', size='large')



    f.savefig(path + '/' + name + '.png', dpi=200)
    plt.show()
开发者ID:irscut,项目名称:IR-SemanticHashing-Python,代码行数:33,代码来源:pca.py


示例13: compute_graph

def compute_graph(players, start, end, resolution, delta,  position="allround"):
	import collections
	import matplotlib.cm as cm
	import numpy
	q = Archiv.objects.filter(
		Q(game__time__gt = start),
		Q(game__time__lt = end),
		reduce(lambda q1, q2: q1 | q2, map(lambda p: Q(player = p), players))
	    ).order_by('game__time')
 	start=q[0].game.time
	data_plot = dict()
	colors = [c for c in cm.rainbow(numpy.linspace(0,1,len(players)))]
	for skill_record in q:
        	if skill_record.player not in data_plot:
			data_plot[skill_record.player] = dict()
			data_plot[skill_record.player]['color'] = colors.pop()
            		data_plot[skill_record.player]["skill"] = collections.OrderedDict()
			data_plot[skill_record.player]["skill"][start-datetime.timedelta(**{'days': delta})] = 700
		#data_plot[skill_record.player]["skill"][resolution(skill_record.game.time)] = skill_record.player.skill(position=position)
		if position=="offensiv":
			data_plot[skill_record.player]["skill"][resolution(skill_record.game.time)] = compute_skill(skill_record.mu_off,skill_record.sigma_off)
		elif position=="defensiv":
                        data_plot[skill_record.player]["skill"][resolution(skill_record.game.time)] = compute_skill(skill_record.mu_def,skill_record.sigma_def)
		else:
			data_plot[skill_record.player]["skill"][resolution(skill_record.game.time)] = compute_skill(skill_record.mu,skill_record.sigma)
	#colors = cm.rainbow(numpy.linspace(0,1,len(players)))
	#print(data_plot)
	return {p: ds for p, ds in data_plot.items()} 
开发者ID:mopshizz,项目名称:kicker_app,代码行数:28,代码来源:functions.py


示例14: fingerprint

def fingerprint(disp_sim_spin = True,n_sim_spins = 13,xrange = [0,20],):


    ###################
    # Add simulated spins #
    ###################

    if disp_sim_spin == True:
            HF_par =   [hf['C1']['par'],hf['C2']['par'],hf['C3']['par'], hf['C4']['par'], hf['C5']['par'], hf['C6']['par'], hf['C7']['par'], hf['C8']['par'], hf['C9']['par'], hf['C10']['par'],   hf['C11']['par'], hf['C12']['par']]
            HF_perp =   [hf['C1']['perp'],hf['C2']['perp'],hf['C3']['perp'], hf['C4']['perp'], hf['C5']['perp'], hf['C6']['perp'], hf['C7']['perp'], hf['C8']['perp'], hf['C9']['perp'], hf['C10']['perp'],   hf['C11']['perp'], hf['C12']['perp']]

            #msmp1_f from hdf5 file
            # msm1 from hdf5 file
            # ZFG g_factor from hdf5file
            B_Field = 304.12 # use magnet tools  Bz = (msp1_f**2 - msm1_f**2)/(4.*ZFS*g_factor)

            tau_lst = np.linspace(0,72e-6,10000)
            Mt16 = SC.dyn_dec_signal(HF_par,HF_perp,B_Field,16,tau_lst)
            FP_signal16 = ((Mt16+1)/2)

    ## Data location ##
    timestamp ='20140419_005744'
    if os.name =='posix':
      ssro_calib_folder = '//Users//Adriaan//Documents//teamdiamond//data//20140419//111949_AdwinSSRO_SSROCalibration_Hans_sil1'
    else:
      ssro_calib_folder = 'd:\\measuring\\data\\20140419\\111949_AdwinSSRO_SSROCalibration_Hans_sil1'
    a, folder = load_mult_dat(timestamp, number_of_msmts = 140, ssro_calib_folder=ssro_calib_folder)

    ###############
    ## Plotting ###
    ###############

    fig = a.default_fig(figsize=(35,5))
    ax = a.default_ax(fig)
    # ax.set_xlim(15.0,15.5)
    ax.set_xlim(xrange)
    start, end = ax.get_xlim()
    ax.xaxis.set_ticks(np.arange(start, end, 0.5))

    ax.set_ylim(-0.05,1.05)
    ax.plot(a.sweep_pts, a.p0, '.-k', lw=0.4,label = 'data') #N = 16
    if disp_sim_spin == True:
      colors = cm.rainbow(np.linspace(0, 1, n_sim_spins))
      for tt in range(n_sim_spins):
        ax.plot(tau_lst*1e6, FP_signal16[tt,:] ,'-',lw=.8,label = 'spin' + str(tt+1))#, color = colors[tt])
    if False:
        tot_signal = np.ones(len(tau_lst))
        for tt in range(n_sim_spins):
          tot_signal = tot_signal * Mt16[tt,:]
        fin_signal = (tot_signal+1)/2.0
        ax.plot(tau_lst*1e6, fin_signal,':g',lw=.8,label = 'tot')


    plt.legend(loc=4)

    print folder
    plt.savefig(os.path.join(folder, str(disp_sim_spin)+'fingerprint.pdf'),
        format='pdf')
    plt.savefig(os.path.join(folder, str(disp_sim_spin)+'fingerprint.png'),
        format='png')
开发者ID:machielblok,项目名称:analysis,代码行数:60,代码来源:fingerprint_analysis_N16.py


示例15: displayPowerSpectrum

def displayPowerSpectrum(*args):

	fig = plt.figure(1)
	ax = fig.add_subplot(111)
	colors = iter(cm.rainbow(np.linspace(0, 1, len(args))))

	for a in args:
		dataPowerSpectrum = calculatePowerSpectrum(a.matrix)

		n     = dataPowerSpectrum.size
		xpoly = np.array(range(1,n + 1))

		p = ax.plot(xpoly, dataPowerSpectrum, color=next(colors), label=a.name)

		Fs     = 1/a.data_step[0]
		tmp    = 1/( Fs/2 * np.linspace(1e-2, 1, int(xpoly.size/6)) )
		ax.set_xticks( np.linspace(1,xpoly.size,tmp.size) )
		ax.set_xticklabels( ["%.1f" % member for member in tmp]  )
		del tmp

	plt.yscale('log')
	plt.grid(linestyle='dotted')
	plt.ylabel('Power Spectrum (|f|^2)')
	plt.xlabel('Frequency')
	plt.legend(loc=3)

	plt.show()
开发者ID:delarosatrevin,项目名称:resmap,代码行数:27,代码来源:ResMap_spectrumTools.py


示例16: scatter_matrix_with_categoricals

def scatter_matrix_with_categoricals(data,
                                     col1,
                                     col2,
                                     categorical_param,
                                     figsize=(10, 6),
                                     alpha=0.75):
                                     
    categorials = data[categorical_param].unique()
    colors = cm.rainbow(np.linspace(0,
                                    1,
                                    len(categorials)))

    color_cycle = cycle(colors)

    plt.figure(figsize=figsize)

    for c in categorials:
        plt.scatter(data[col1][data[categorical_param] == c],
                    data[col2][data[categorical_param] == c],
                    alpha=alpha,
                    color=color_cycle.next(),
                    label=c)

    plt.xlabel(col1)
    plt.ylabel(col2)
    plt.legend(loc='best')
    plt.show()
开发者ID:AzunaiML,项目名称:MailRU_ML,代码行数:27,代码来源:scatter_matrix_with_categoricals.py


示例17: _get_colours

 def _get_colours(self, colours, rainbow=False):  # pragma: no cover
     num_chains = len(self.chains)
     if rainbow or num_chains > len(colours):
         colours = cm.rainbow(np.linspace(0, 1, num_chains))
     else:
         colours = colours[:num_chains]
     return colours
开发者ID:Samreay,项目名称:Wigglez,代码行数:7,代码来源:chain.py


示例18: _DrawHistogram

def _DrawHistogram(axis, results):
  values_per_commit = [values for _, values in results]

  # Calculate bounds and bins.
  combined_values = sum(values_per_commit, [])
  lower_bound = min(combined_values)
  upper_bound = max(combined_values)
  if lower_bound == upper_bound:
    lower_bound -= 0.5
    upper_bound += 0.5
  bins = numpy.linspace(lower_bound, upper_bound,
                        math.log(len(combined_values)) * 4)

  # Histograms.
  colors = cm.rainbow(numpy.linspace(  # pylint: disable=no-member
      1, 0, len(results) + 1))
  for (commit, values), color in zip(results, colors):
    axis.hist(values, bins, alpha=0.5, normed=True, histtype='stepfilled',
              label='%s (n=%d)' % (commit, len(values)), color=color)

  # Vertical lines denoting the medians.
  medians = tuple(numpy.percentile(values, 50) for values in values_per_commit)
  axis.set_xticks(medians, minor=True)
  axis.grid(which='minor', axis='x', linestyle='--')

  # Axis labels and legend.
  #axis.set_xlabel(step.metric_name)
  axis.set_ylabel('Relative probability')
  axis.legend(loc='upper right')
开发者ID:catapult-project,项目名称:catapult,代码行数:29,代码来源:plot_bisect_results.py


示例19: Visualize

def Visualize(Tlist,sigmalist, nsamples = 100):
  """
  Visualize an estimation (a point will be used to represent the translation position of a transformation)
  @param Tlist:     a list of Transformations
  @param sigmalist: a list of corresponding sigmas
  @param nsamples:  the number of samples generated for each (T,sigma)
  """
  import matplotlib.cm as cm
  fig = plt.figure()
  ax = fig.add_subplot(111, projection='3d')
  cholsigmalist = []
  colors = iter(cm.rainbow(np.linspace(0, 1, len(Tlist))))
  for i in range(len(sigmalist)):
    color = next(colors)
    cholsigma = np.linalg.cholesky(sigmalist[i]).T
    Tsample = []
    for k in range(nsamples):
      vecsample = np.dot(cholsigma,np.random.randn(6,1))
      #vecsample = np.dot(cholsigma, np.random.uniform(-1,1,size = 6))
      vecsample.resize(6)
      Tsample = np.dot(VecToTran(vecsample), Tlist[i])
      ax.scatter(Tsample[0,3],Tsample[1,3],Tsample[2,3], c = color)

  ax.set_autoscaley_on(False)
  ax.set_xlim([-0.5, 0.5])
  ax.set_ylim([-0.5, 0.5])
  ax.set_zlim([-0.5, 0.5])
  ax.set_xlabel('X Label')
  ax.set_ylabel('Y Label')
  ax.set_zlabel('Z Label')
  plt.show(False)
  return True
开发者ID:dinhhuy2109,项目名称:python-cope,代码行数:32,代码来源:SE3UncertaintyLib.py


示例20: scatterPlotForFeatures

def scatterPlotForFeatures(df, f1,f2,legend1,legend2):
    f1=f1.split(".")
    f2=f2.split(".")
    handler=getTrainingHandler()
    darr=df.map(lambda s: ( handler.computeClassification(s),(\
        reduce(lambda x,y: getattr(x,y) if isinstance(x, Row) else getattr(getattr(s,x),y), f1) if len(f1)>1 else getattr(s,f1[0]),\
        reduce(lambda x,y: getattr(x,y) if isinstance(x, Row) else getattr(getattr(s,x),y), f2) if len(f2)>1 else getattr(s,f2[0])\
        )))\
        .reduceByKey(lambda x,y: makeList(x) + makeList(y))\
        .collect()
    numClasses=getTrainingHandler().numClasses()
    citer=iter(cm.rainbow(np.linspace(0, 1, numClasses)))
    colors = [next(citer) for i in range(0, numClasses)]
    legends= [getTrainingHandler().getClassLabel(i) for i in range(0,numClasses)]
    sets=[]
    for t in darr:
        sets.append((plt.scatter([x[0] for x in t[1]],[x[1] for x in t[1]],
                     color=colors[t[0]],alpha=0.5),legends[t[0]]))

    params = plt.gcf()
    plSize = params.get_size_inches()
    params.set_size_inches( (plSize[0]*3, plSize[1]*2) )
    plt.ylabel(legend2)
    plt.xlabel(legend1)
    plt.legend([x[0] for x in sets],
               [x[1] for x in sets],
               scatterpoints=1,
               loc='lower left',
               ncol=numClasses,
               fontsize=12)
    plt.show()
开发者ID:ibm-cds-labs,项目名称:simple-data-pipe-connector-flightstats,代码行数:31,代码来源:training.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python cm.register_cmap函数代码示例发布时间:2022-05-27
下一篇:
Python cm.jet函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap