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

Python pyplot.xscale函数代码示例

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

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



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

示例1: make_coefficient_plot

def make_coefficient_plot(table, positive_words, negative_words, l2_penalty_list):
    cmap_positive = plt.get_cmap('Reds')
    cmap_negative = plt.get_cmap('Blues')

    xx = l2_penalty_list
    plt.plot(xx, [0.]*len(xx), '--', lw=1, color='k')

    table_positive_words = table.filter_by(column_name='word', values=positive_words)
    table_negative_words = table.filter_by(column_name='word', values=negative_words)
    del table_positive_words['word']
    del table_negative_words['word']

    for i in xrange(len(positive_words)):
        color = cmap_positive(0.8*((i+1)/(len(positive_words)*1.2)+0.15))
        plt.plot(xx, table_positive_words[i:i+1].to_numpy().flatten(),
                 '-', label=positive_words[i], linewidth=4.0, color=color)

    for i in xrange(len(negative_words)):
        color = cmap_negative(0.8*((i+1)/(len(negative_words)*1.2)+0.15))
        plt.plot(xx, table_negative_words[i:i+1].to_numpy().flatten(),
                 '-', label=negative_words[i], linewidth=4.0, color=color)

    plt.legend(loc='best', ncol=3, prop={'size':16}, columnspacing=0.5)
    plt.axis([1, 1e5, -1, 2])
    plt.title('Coefficient path')
    plt.xlabel('L2 penalty ($\lambda$)')
    plt.ylabel('Coefficient value')
    plt.xscale('log')
    plt.rcParams.update({'font.size': 18})
    plt.tight_layout()
开发者ID:caschindler,项目名称:machine-learning,代码行数:30,代码来源:logistic_regression-gradient_ascent_l2_regularization.py


示例2: main

def main():

    sample='q'
    sm_bin='10.0_10.5'
    catalogue = 'sm_9.5_s0.2_sfr_c-0.75_250'

    #load in fiducial mock
    filepath = './'
    filename = 'sm_9.5_s0.2_sfr_c-0.8_Chinchilla_250_wp_fiducial_'+sample+'_'+sm_bin+'_cov.npy'
    cov = np.matrix(np.load(filepath+filename))
    diag = np.diagonal(cov)
    filepath = cu.get_output_path() + 'analysis/central_quenching/observables/'
    filename = 'sm_9.5_s0.2_sfr_c-0.8_Chinchilla_250_wp_fiducial_'+sample+'_'+sm_bin+'.dat'
    data = ascii.read(filepath+filename)
    rbins = np.array(data['r'])
    mu = np.array(data['wp'])
    
    #load in comparison mock
    
    
    
    
    plt.figure()
    plt.errorbar(rbins, mu, yerr=np.sqrt(np.diagonal(cov)), color='black')
    plt.plot(rbins, wp,  color='red')
    plt.xscale('log')
    plt.yscale('log')
    plt.show()
    
    inv_cov = cov.I
    Y = np.matrix((wp-mu))
    
    X = Y*inv_cov*Y.T
    
    print(X)
开发者ID:duncandc,项目名称:mpeak_vpeak_mock,代码行数:35,代码来源:chi_squared_corr_create_mock.py


示例3: plot_figure_commute

def plot_figure_commute(file_name):
    f = open(file_name)
    lines = f.readlines()
    lines[0] = lines[0][:-1]
    f.close()

    probabilities = lines[0].split(" ")
    xx = xrange(len(probabilities))
    probabilities = [float(x) for x in probabilities]

    plt.figure(figsize=(12, 10))
    plt.plot(xx, probabilities, label="D(degree > x)")
    plt.ylabel('Percentage of vertices which degree> x')
    plt.xlabel('Degree')
    plt.title("Cumulative function for degrees")
    plt.legend(loc='upper right')

    name = "results_graphs/"
    if file_name == "temp_degrees/cumulative_temp.txt":
        name += "ful_cumulative"
    else:
        name += "good_cumulative"

    plt.savefig(name + '.png')

    plt.figure(figsize=(12, 10))
    plt.plot(xx, probabilities, label="log(D(degree > x))")
    plt.legend(loc='upper right')
    plt.title("Cumulative function for degrees in log/log coords")
    plt.ylabel('Log of percentage of vertices which degree> x')
    plt.xlabel('Log of degrees')
    plt.xscale('log')
    plt.yscale('log')

    plt.savefig(name + '_log' + '.png')
开发者ID:AkmalArtikov,项目名称:ComplexNetworks,代码行数:35,代码来源:plot.py


示例4: pareto_graph

def pareto_graph(database, objectives=None):
	'''Constructs a visualization of the movement of the best front over generations

	The argument 'objectives' must be a list indicating the indices of the fitness values to be used.
	The first two will be consumed. If the list has less than two elements, or if is not given, the
	graph will be produced using the first two fitness values.
	'''
	if objectives is None or len(objectives) < 2:
		objectives = [0, 1]

	generations = []
	if database.properties['highest_population'] < FRONT_COUNT:
		generations = list(range(1, database.properties['highest_population'] + 1))
	else:
		step = database.properties['highest_population'] / FRONT_COUNT
		generations = [round(i * step) for i in range(1, FRONT_COUNT + 1)]

	for i, gen in enumerate(generations, start=1):
		database.select(gen)
		individual_data = [val for key, val in database.load_report().items()
			if key.startswith('I') and val['rank'] == 1]
		x_values = [val['fitness'][objectives[0]] for val in individual_data]
		y_values = [val['fitness'][objectives[1]] for val in individual_data]
		plt.plot(x_values, y_values,
			color=str((FRONT_COUNT - i) / FRONT_COUNT),
			linestyle='None',
			marker='o',
			markeredgecolor='white')

	plt.title('Movement of best front')
	plt.xscale('log')
	plt.yscale('log')
	plt.xlabel(database.properties['objective_names'][objectives[0]])
	plt.ylabel(database.properties['objective_names'][objectives[1]])
	plt.show()
开发者ID:LuisLaraP,项目名称:RobotNSGA,代码行数:35,代码来源:pareto.py


示例5: fluence_dist

    def fluence_dist(self):
        """ Plots the fluence distribution and gives the mean and median fluence
        values of the sample """
        fluences = []
        for i in range(0,len(self.fluences),1):
            try:
                fluences.append(float(self.fluences[i]))

            except ValueError:
                continue

        fluences = np.array(fluences)
        mean_fluence = np.mean(fluences)
        median_fluence = np.median(fluences)
        print('Mean Fluence =',mean_fluence,'(15-150 keV) [10^-7 erg cm^-2]')
        print('Median Fluence =',median_fluence,'(15-150 keV) [10^-7 erg cm^-2]')

        plt.figure()
        plt.xlabel('Fluence (15-150 keV) [$10^{-7}$ erg cm$^{-2}$]')
        plt.ylabel('Number of GRBs')
        plt.xscale('log')
        minimum, maximum = min(fluences), max(fluences)
        plt.axvline(mean_fluence,color='red',linestyle='-')
        plt.axvline(median_fluence,color='blue',linestyle='-')
        plt.hist(fluences,bins= 10**np.linspace(np.log10(minimum),np.log10(maximum),20),color='grey',alpha=0.5)
        plt.show()
开发者ID:jtwm1,项目名称:adampy,代码行数:26,代码来源:swift_functions.py


示例6: dose_plot

def dose_plot(df,err,cols,scale='linear'):
    n_rows = int(np.ceil(len(cols)/3.0))
    plt.figure(figsize=(20,4 * n_rows))
    subs = gridspec.GridSpec(n_rows, 3) 
    plt.subplots_adjust(hspace=0.54,wspace=0.27)

    for col,sub in zip(cols,subs):
        plt.subplot(sub)
        for base in df['Base'].unique():
            for drug in get_drugs_with_multiple_doses(filter_rows(df,'Base',base)):
                data = thread_first(df,
                                    (filter_rows,'Drug',drug),
                                    (filter_rows,'Base',base),
                                    (DF.sort, 'Dose'))
                error = thread_first(err,
                                     (filter_rows,'Drug',drug),
                                     (filter_rows,'Base',base),
                                     (DF.sort, 'Dose'))
                if scale == 'linear':
                    plt.errorbar(data['Dose'],data[col],yerr=error[col])
                    title = "{} vs. Dose".format(col)
                else: 
                    plt.errorbar(data['Dose'],data[col],yerr=error[col])
                    plt.xscale('log')
                    title = "{} vs. Dose (Log Scale)".format(col)
                    plt.xticks(data['Dose'].values,data['Dose'].values)
                    plt.xlim(0.06,15)
                label('Dose ({})'.format(data.Unit.values[0]), col,title,fontsize = 15)

                plt.legend(df['Base'].unique(), loc = 0)
开发者ID:dela3499,项目名称:assay-explorer,代码行数:30,代码来源:view.py


示例7: set_axis_properties

def set_axis_properties(p,metric,varying_parameter,group):

    #Set major x-axis label
    plt.xlabel(xlabel_names[varying_parameter])

    #Set x-axis scale
    xscale_args = xscale_arguments[(metric,varying_parameter)]
    plt.xscale(xscale_args[0],**xscale_args[1])

    #Set x-axis tick labels
    #Get tick values
    ticks = list(sp.unique(group[varying_parameter]))

    #If an item is not in the tick dictionary for the bar plot, add it
    if pltkind[(metric,varying_parameter)] is 'bar':
        for item in ticks:
            if item not in varying_xlabels[varying_parameter].keys():
                varying_xlabels[varying_parameter][item] = '$' + str(item) +'$'

    xlabels = [ varying_xlabels[varying_parameter][item] for item in ticks]

    if pltkind[(metric,varying_parameter)] is 'bar':
        p.set_xticks(sp.arange(len(ticks))+0.5)
        plt.setp(p.set_xticklabels(xlabels), rotation=0)
    else:
        plt.xticks(ticks,xlabels)

    plt.ylabel(ylabel_names[metric])
    plt.grid('on')
开发者ID:steinwurf,项目名称:storage-benchmarks,代码行数:29,代码来源:plot_storage_helper.py


示例8: plotCurves

def plotCurves(losses,rateOfExceedance,return_periods,lossLevels):

    plt.figure(1, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
    plt.scatter(losses,rateOfExceedance,s=20)
    if len(return_periods) > 0:
        annual_rate_exc = 1.0/np.array(return_periods)
        for rate in annual_rate_exc:
            if rate > min(rateOfExceedance):
                plt.plot([min(losses),max(losses)],[rate,rate],color='red') 
                plt.annotate('%.6f' % rate,xy=(max(losses),rate),fontsize = 12)

    plt.yscale('log')
    plt.xscale('log')
    plt.ylim([min(rateOfExceedance),1])
    plt.xlim([min(losses),max(losses)])
    plt.xlabel('Losses', fontsize = 16)
    plt.ylabel('Annual rate of exceedance', fontsize = 16)

    setReturnPeriods = 1/rateOfExceedance
    plt.figure(2, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k')
    plt.scatter(setReturnPeriods,losses,s=20)
    if len(return_periods) > 0:
        for period in return_periods:
            if period < max(setReturnPeriods):
                plt.plot([period,period],[min(losses),max(losses)],color='red') 
                plt.annotate(str(period),xy=(period,max(losses)),fontsize = 12)

    plt.xscale('log')
    plt.xlim([min(setReturnPeriods),max(setReturnPeriods)])
    plt.ylim([min(losses),max(losses)])
    plt.xlabel('Return period (years)', fontsize = 16)
    plt.ylabel('Losses', fontsize = 16)
开发者ID:lmcsousa,项目名称:rmtk,代码行数:32,代码来源:loss_modelling.py


示例9: plot_netload_cache_size_sensitivity

def plot_netload_cache_size_sensitivity(show=True, save=True):
    """
    Plot sensitivity of network load vs cache size
    """
    # Parameters
    T = TOPOLOGIES
    C = C_RANGE
    A = ALPHA_C_PLOT
    LT = LINK_TYPES
    # Execution
    for t in T:
        for a in [str(al) for al in A]:
            for lt in LT:
                plt.figure()
                plt.title('Network load: LINK=%s T=%s A=%s' % (lt, t, a))
                plt.ylabel('Average link load (Mbps)')
                plt.xlabel('Cache to population ratio')
                plt.xscale('log')
                S = SummaryAnalyzer(path.join(SUMMARY_LOG_DIR, 'SUMMARY_NETWORK_LOAD.txt'))
                for strategy in NETLOAD_STRATEGIES:
                    cond = (S.param['T'] == t) &  (S.param['A'] == a) &  (S.param['S'] == strategy) & (S.data['LinkType'] == lt)
                    plt.plot(S.param['C'][cond], S.data['NetworkLoad'][cond], style_dict[strategy])
                plt.xlim(min(C), max(C))
                plt.legend(tuple(netload_legend_list), prop={'size': LEGEND_SIZE}, loc='lower left')
                if show: plt.show()
                if save: plt.savefig(path.join(GRAPHS_DIR ,'NETLOAD_C_SENS_LT=%[email protected]=%[email protected]=%s.pdf' % (lt, t, a)), bbox_inches='tight')
开发者ID:Estoque86,项目名称:Icarus,代码行数:26,代码来源:plot.py


示例10: __save

    def __save(self, n, plot, sfile):
        p.figure(figsize=sfile)

        p.xlabel(plot.xlabel)
        p.ylabel(plot.ylabel)
        p.xscale(plot.xscale)
        p.yscale(plot.yscale)
        p.grid()
        for curvetype, args, kwargs in plot.curves:
            if curvetype == "plot":
                p.plot(*args, **kwargs)
            elif curvetype == "imshow":
                p.imshow(*args, **kwargs)
            elif curvetype == "hist":
                p.hist(*args, **kwargs)
            elif curvetype == "bar":
                p.bar(*args, **kwargs)

        p.axes().set_aspect(plot.aspect)
        if plot.legend:
            p.legend(shadow=0, loc=plot.loc)

        if not os.path.isdir(plot.dir):
            os.mkdir(plot.dir)
        if plot.pgf:
            p.savefig(plot.dir + plot.name + ".pgf")
            print(plot.name + ".pgf")
        if plot.pdf:
            p.savefig(plot.dir + plot.name + ".pdf", bbox_inches="tight")
            print(plot.name + ".pdf")

        p.close()
开发者ID:simphys,项目名称:exercises,代码行数:32,代码来源:plotter.py


示例11: plot_citation_graph

def plot_citation_graph(citation_graph, filename, plot_title):
    # find the indegree_distribution
    indeg_dist = in_degree_distribution(citation_graph)    
    # sort freq by keys
    number_citations = sorted(indeg_dist.keys())
    indeg_freq = [indeg_dist[n] for n in number_citations]

    # normalize
    total = sum(indeg_freq)
    indeg_freq_norm = [freq / float(total) for freq in indeg_freq]
    
    # calculate log/log, except for the first one (0)
    #log_number_citations = [math.log10(x) for x in number_citations[1:]]
    #log_indeg_freq_norm = [math.log10(x) for x in indeg_freq_norm[1:]]
    
    plot(number_citations[1:], indeg_freq_norm[1:], 'o')
    
    xscale("log")
    yscale("log")
    
    xlabel("log10 #citations")
    ylabel("log10 Norm.Freq.")
    title(plot_title)
    grid(True)
    savefig(filename)
    show()
开发者ID:jglara,项目名称:algothink,代码行数:26,代码来源:citation.py


示例12: setDiffsPlot

def setDiffsPlot(CF,d0,ySym = True):
    CFtext = [str(j)+',' for j in CF]
    bText = [CFtext[0],r'...,$a_i$+c,...',CFtext[-1]]
    CFtext = ''.join(CFtext)
    bText= ''.join(bText)
    CFtext = '[' + CFtext[:-1] + ']'
    bText = '[' + bText[:-1] + ']'
    print(CFtext)

    plt.ylabel(r'$d^{crit}_b - d^{crit}_a$',fontsize=20)
    plt.xlabel(r'Element changed',fontsize=20)
    xmin, xmax, ymin, ymax = plt.axis()
    if ySym:
        plt.yscale('symlog',linthreshy=1e-15)
        yLoc = [y*ymax for y in [.1, .01, .001]]
    else:
        yLoc = [y*(ymax-ymin)+ymin for y in [0.95, 0.85, 0.75]]
    plt.plot([0,xmax],[0,0],'k--',label='_')
    plt.text((xmax-xmin)*0.15,yLoc[0],r'$a = [a_i] =$'+CFtext,fontsize=15)
    plt.text((xmax-xmin)*0.15,yLoc[1],r'$b_i = $'+bText,fontsize=15)
    plt.text((xmax-xmin)*0.15,yLoc[2],r'$d_a^{crit} = $'+str(float(d0)),fontsize=15)
    plt.legend(loc='best')
    plt.xscale('symlog',linthreshx=1e-14)
    # plt.yscale('log')
    plt.show()
开发者ID:thaaemis,项目名称:fractal,代码行数:25,代码来源:dCrit.py


示例13: main

def main():
    counter = n36.main()
    plt.figure()
    plt.xscale('log')
    plt.yscale('log')
    plt.plot(sorted(list(counter.values()), reverse=True), range(1, len(list(counter)) + 1))
    plt.savefig('fig39.png')
开发者ID:chantera,项目名称:nlp100,代码行数:7,代码来源:n39.py


示例14: nlp39

def nlp39(words):
    # Zipfの法則:https://ja.wikipedia.org/wiki/%E3%82%B8%E3%83%83%E3%83%97%E3%81%AE%E6%B3%95%E5%89%87

    # 語彙頻度
    freq = {}
    for word in words:
        if word['pos'] == '動詞':
            if not word['base'] in freq:
                freq[word['base']] = 1
            else:
                freq[word['base']] += 1

    count = 1
    x = []
    y = []
    for word in sorted(freq, key=freq.get, reverse=True):
        x.append(count)
        y.append(freq[word])
        count += 1

    plt.xscale('log')
    plt.yscale('log')

    plt.plot(x, y, 'o')
    plt.show()
开发者ID:YukihiroMoriyama,项目名称:python_nlp_100practice,代码行数:25,代码来源:nlp30-39.py


示例15: PlotEDepSummary

def PlotEDepSummary(gFiles,nFiles,figureName='EDepSummary.png',tParse=GetThickness,
  histKey='eDepHist'):
  """ PlotEDepSummary
  Plotss the energy deposition summary
  """
  # Extrating the average values
  gT = list()
  gDep = list()
  gDepError = list()
  nT = list()
  nDep = list()
  nDepError = list()
  for fname in gFiles:
    f = TFile(fname,'r')
    hist = f.Get(histKey)
    gT.append(GetThickness(fname))
    gDep.append(hist.GetMean())
    gDepError.append(hist.GetMeanError())
  for fname in nFiles:
    f = TFile(fname,'r')
    hist = f.Get(histKey)
    nT.append(GetThickness(fname))
    nDep.append(hist.GetMean())
    nDepError.append(hist.GetMeanError())
  # Plotting
  plt.errorbar(gT,gDep,yerr=gDepError,fmt='r+')
  plt.hold(True)
  plt.errorbar(nT,nDep,yerr=nDepError,fmt='go')
  plt.xlabel("Thickness (mm)")
  plt.ylabel("Average Energy Deposition (MeV)")
  plt.legend(["Co-60","Cf-252"])
  plt.xscale("log")
  plt.yscale("log")
  plt.grid(True)
  plt.savefig(figureName)
开发者ID:architkumar02,项目名称:murphs-code-repository,代码行数:35,代码来源:analysis.py


示例16: SetAxes

def SetAxes(legend=False):
    f_b = 0.164
    f_star = 0.01
    err_b = 0.006
    err_star = 0.004
    f_gas = f_b - f_star
    err_gas = np.sqrt(err_b**2 + err_star**2)

    plt.axhline(y=f_gas, ls='--', c='k', label='', zorder=-1)
    x = np.linspace(.0,2.,1000)
    plt.fill_between(x, y1=f_gas - err_gas, y2=f_gas + err_gas, color='k', alpha=0.3, zorder=-1)
    plt.text(.6, f_gas+0.006, r'f$_{gas}$', verticalalignment='bottom', size='large')
    plt.xlabel(r'r/r$_{vir}$', size='x-large')
    plt.ylabel(r'f$_{gas}$ ($<$ r)', size='x-large')

    plt.xscale('log')
    plt.xticks([1./1.9, 1.33/1.9, 1, 1.5, 2.],[r'r$_{500}$', r'r$_{200}$', 1, 1.5, 2], size='large')
    #plt.yticks([.1, .2], ['0.10', '0.20'])
    plt.tick_params(length=10, which='major')
    plt.tick_params(length=5, which='minor')
    plt.xlim([0.4,1.5])
    plt.minorticks_on()

    if legend:
        plt.legend(loc=0, prop={'size':'small'}, markerscale=0.7, numpoints=1, ncol=2)
开发者ID:bacook17,项目名称:PU_Thesis,代码行数:25,代码来源:PlotFgvR.py


示例17: plot

def plot(objects, xscales={}, yscales={}, title=""):
    from matplotlib.pyplot import plot, show, close, subplot,\
        xscale, yscale, gcf
    '''
    Plots current state of objects in subplots.
    Define xscales and yscales as dict of indexes.
    '''
    if not isinstance(objects, list):
            objects = [objects]

    l = len(objects)
    first = round(l / 2.0) + 1
    second = round(l / 2.0)
    for i in range(0, l):
        subplot(first, second, i + 1)
        if i in xscales:
            xscale(xscales[i])
        if i in yscales:
            yscale(yscales[i])
        fig = gcf()
        fig.suptitle(title, fontsize="x-large")

        values = objects[i].get_y_values()
        x, y = values.shape

        for j in range(x):
            plot(objects[i].get_t_values(), values[j, :])

    show()
    close()
开发者ID:Scoudem,项目名称:modsim,代码行数:30,代码来源:integration.py


示例18: create_scatter

def create_scatter(datax, datay, x_label, y_label, filename, title=None,
                   log=False, set_same=False, colors=None,
                   num_colors=None, color_map=None, xlims=None, ylims=None):
    """Given a set of data, create a scatter plot of the data, optionally
    in log format

    """
    plt.figure()
    plt.grid()
    if colors is not None:
        plt.scatter(datax, datay, marker='x', c=colors, s=num_colors,
                    cmap=color_map)
    else:
        plt.scatter(datax, datay, marker='x')
    plt.xlabel(x_label)
    plt.ylabel(y_label)

    if log:
        plt.xscale('log')

    if xlims is not None:
        plt.xlim(xlims)
    if ylims is not None:
        plt.ylim(ylims)

    if set_same:
        ylims = plt.ylim()
        plt.xlim(ylims)
    if title is not None:
        plt.title(title)
    plt.tight_layout()
    plt.savefig(filename, fmt='pdf')
开发者ID:ben-jones,项目名称:skyline-streaming,代码行数:32,代码来源:graphing.py


示例19: check_hod

 def check_hod(self, z, prop):
     data = np.genfromtxt(LOCATION + "/data/" + prop + "z" + str(z))
     if prop == "ncen":
         if PLOT:
             plt.clf()
             plt.plot(self.hod.hmf.M,
                      self.hod.n_cen,
                      label="mine")
             plt.plot(data[:, 0] * self.hod.cosmo.h, data[:, 1], label="charles")
             plt.legend()
             plt.xscale('log')
             plt.yscale('log')
             plt.savefig(join(pref, "ncen" + prop + "z" + str(z) + ".pdf"))
         assert max_diff_rel(self.hod.n_cen, data[:, 1], 0.01)
     elif prop == "nsat":
         if PLOT:
             plt.clf()
             plt.plot(self.hod.hmf.M,
                      self.hod.n_sat,
                      label="mine")
             plt.plot(data[:, 0] * self.hod.cosmo.h, data[:, 1], label="charles")
             plt.legend()
             plt.xscale('log')
             plt.yscale('log')
             plt.savefig(join(pref, "nsat" + prop + "z" + str(z) + ".pdf"))
         assert max_diff_rel(self.hod.n_sat, data[:, 1], 0.01)
开发者ID:prollejazz,项目名称:halomod,代码行数:26,代码来源:test_known_results.py


示例20: avgDegree

def avgDegree(G):
  print "Nodes: ",
  print G.number_of_nodes()
  print "Edges: ",
  print G.number_of_edges()

  # avg degree
  degrees = defaultdict(int)
  total = 0
  for node in G.nodes():
    neighbors = G.neighbors(node)
    degrees[len(neighbors)] += 1
    total += len(neighbors)

  max_degree = max(degrees.keys())
  degrees_arr = (max_degree+1) * [0]
  for index, count in degrees.iteritems():
    degrees_arr[index] = count

  plt.plot(range(max_degree+1), degrees_arr, '.')
  plt.xscale('log', basex=2)
  plt.xlabel('degree')
  plt.yscale('log', basex=2)
  plt.ylabel('# of people')
  plt.savefig('degree_distribution.png')
  plt.close()
开发者ID:Laurawly,项目名称:yelp,代码行数:26,代码来源:gutils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pyplot.xticks函数代码示例发布时间:2022-05-27
下一篇:
Python pyplot.xlim函数代码示例发布时间: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