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

Python pylab.scatter函数代码示例

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

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



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

示例1: generate_pr_scatter_plots

def generate_pr_scatter_plots(
    query_prf, subject_prf, query_color="b", subject_color="r", x_label="Precision", y_label="Recall"
):
    """ Generate scatter plot of precision versus recall for query and subject results
        
        query_prf: precision, recall, and f-measure values as returned 
         from compute_prfs for query data
        subject_prf: precision, recall, and f-measure values as returned 
         from compute_prfs for subject data
        query_color: the color of the query points (defualt: blue)
        subject_color: the color of the subject points (defualt: red)
        x_label: x axis label for the plot (default: "Precision")
        y_label: y axis label for the plot (default: "Recall")
    
    """

    # Extract the query precisions and recalls and
    # generate a scatter plot
    query_precisions = [e[4] for e in query_prf]
    query_recalls = [e[5] for e in query_prf]
    scatter(query_precisions, query_recalls, c=query_color)

    # Extract the subject precisions and recalls and
    # generate a scatter plot
    subject_precisions = [e[4] for e in subject_prf]
    subject_recalls = [e[5] for e in subject_prf]
    scatter(subject_precisions, subject_recalls, c=subject_color)

    xlim(0, 1)
    ylim(0, 1)
    xlabel(x_label)
    ylabel(y_label)
开发者ID:jairideout,项目名称:short-read-tax-assignment,代码行数:32,代码来源:eval_framework.py


示例2: plotslice

def plotslice(pos,filename='',boxsize=100.):
    ng = pos.shape[0]
    M.clf()
    M.scatter(pos[ng/4,:,:,1].flatten(),pos[ng/4,:,:,2].flatten(),s=1.,lw=0.)
    M.axis('tight')
    if filename != '':
        M.savefig(filename)
开发者ID:JohanComparat,项目名称:pyLPT,代码行数:7,代码来源:muscle.py


示例3: geweke_plot

def geweke_plot(data, name, format='png', suffix='-diagnostic', path='./', fontmap = None, 
    verbose=1):
    # Generate Geweke (1992) diagnostic plots

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

    # Generate new scatter plot
    figure()
    x, y = transpose(data)
    scatter(x.tolist(), y.tolist())

    # Plot options
    xlabel('First iteration', fontsize='x-small')
    ylabel('Z-score for %s' % name, fontsize='x-small')

    # Plot lines at +/- 2 sd from zero
    pyplot((nmin(x), nmax(x)), (2, 2), '--')
    pyplot((nmin(x), nmax(x)), (-2, -2), '--')

    # Set plot bound
    ylim(min(-2.5, nmin(y)), max(2.5, nmax(y)))
    xlim(0, nmax(x))

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


示例4: plot_polynomial_regression

def plot_polynomial_regression():
    rng = np.random.RandomState(0)
    x = 2*rng.rand(100) - 1
    f = lambda t: 1.2 * t**2 + .1 * t**3 - .4 * t **5 - .5 * t ** 9
    y = f(x) + .4 * rng.normal(size=100)

    x_test = np.linspace(-1, 1, 100)

    pl.figure()
    pl.scatter(x, y, s=4)

    X = np.array([x**i for i in range(5)]).T
    X_test = np.array([x_test**i for i in range(5)]).T
    regr = linear_model.LinearRegression()
    regr.fit(X, y)
    pl.plot(x_test, regr.predict(X_test), label='4th order')

    X = np.array([x**i for i in range(10)]).T
    X_test = np.array([x_test**i for i in range(10)]).T
    regr = linear_model.LinearRegression()
    regr.fit(X, y)
    pl.plot(x_test, regr.predict(X_test), label='9th order')

    pl.legend(loc='best')
    pl.axis('tight')
    pl.title('Fitting a 4th and a 9th order polynomial')

    pl.figure()
    pl.scatter(x, y, s=4)
    pl.plot(x_test, f(x_test), label="truth")
    pl.axis('tight')
    pl.title('Ground truth (9th order polynomial)')
开发者ID:Arjunil,项目名称:BangPypers-SKLearn,代码行数:32,代码来源:plot.py


示例5: pseudoSystem

def pseudoSystem():

	#The corrolations discovered when answering this question shows the emergent effects of component evolution on CSE.
	#We can further study these correlations by creating an example component system consisting of many components where a a different component has a new version released every day.
	#By looking at users who Upgrade the system at different frequencies over 100 days, we present two graphs, Upgrade frequency to uttd and change.	
	
	
	l = 100
	uttdxy = []
	chxy = []
	for uf in range(1,20):
		uttd = range(uf)*(l*2/uf)
		uttd = uttd[1:l+1]
		uttdxy.append((uf,numpy.mean(uttd)))
		
		sh = [0]*(uf-1) + [uf]
		sh = sh*l
		sh = sh[:l]
		chxy.append((uf,sum(sh)))
		
	pylab.figure(20)
	x,y = zip(*sorted(uttdxy))
	pylab.plot(x,y)
	pylab.scatter(x,y)
	saveFigure("q1bpseudouttd")
	
	pylab.figure(21)
	
	x,y = zip(*sorted(chxy))
	pylab.plot(x,numpy.array(y))
	pylab.scatter(x,numpy.array(y))
	pylab.ylim([0,l+10])
	saveFigure("q1bpseudochange")
开发者ID:dloti,项目名称:ComponentSystemEvolutionSimulation,代码行数:33,代码来源:aq1b.py


示例6: test

def test():
    from pandas import DataFrame
    X = np.linspace(0.01, 1.0, 10)
    Y = np.log(X)
    Y -= Y.min()
    Y /= Y.max()
    Y *= 0.95

    #Y = X

    df = DataFrame({'X': X, 'Y': Y})
    P = Pareto(df, 'X', 'Y')

    data = []
    for val in np.linspace(0,1,15):
        data.append(dict(val=val, x=P.lookup_x(val), y=P.lookup_y(val)))
        pl.axvline(val, alpha=.5)
        pl.axhline(val, alpha=.5)
    dd = DataFrame(data)
    pl.scatter(dd.y, dd.val, lw=0, c='r')
    pl.scatter(dd.val, dd.x, lw=0, c='g')
    print dd

    #P.scatter(c='r', lw=0)
    P.show_frontier(c='r', lw=4)
    pl.show()
开发者ID:adi2103,项目名称:arsenal,代码行数:26,代码来源:pareto.py


示例7: plot_values

def plot_values(X, Y, xlabel, ylabel, suffix, ptype='plot'):
    output_filename = constants.ATTRACTIVENESS_FOLDER_NAME + constants.DATASET + '_' + suffix

    X1 = [X[i] for i in range(len(X)) if X[i]>0 and Y[i]>0]
    Y1 = [Y[i] for i in range(len(X)) if X[i]>0 and Y[i]>0]
    X = X1
    Y = Y1
    
    pylab.close("all")
    
    pylab.figure(figsize=(8, 7))

    #pylab.rcParams.update({'font.size': 20})

    pylab.scatter(X, Y)
    
    #pylab.axis(vis.get_bounds(X, Y, False, False))

    #pylab.xscale('log')
    pylab.yscale('log')

    pylab.xlabel(xlabel)
    pylab.ylabel(ylabel)   
    #pylab.xlim(0.1,1)
    #pylab.ylim(ymin=0.01)
    #pylab.tight_layout()

    pylab.savefig(output_filename + '.pdf')
开发者ID:shmueli,项目名称:trend_prediction,代码行数:28,代码来源:visualize_contrast.py


示例8: plot_contour

def plot_contour(X, X1, X2, clf, title):
    pl.figure()
    pl.title(title)

    # Plot instances of class 1.
    pl.plot(X1[:, 0], X1[:, 1], "ro")
    # Plot instances of class 2.
    pl.plot(X2[:, 0], X2[:, 1], "bo")

    # Select "support vectors".
    if hasattr(clf, "support_vectors_"):
        sv = clf.support_vectors_
    else:
        sv = X[clf.coef_.ravel() != 0]

    # Plot support vectors.
    pl.scatter(sv[:, 0], sv[:, 1], s=100, c="g")

    # Plot decision surface.
    A, B = np.meshgrid(np.linspace(-6, 6, 50), np.linspace(-6, 6, 50))
    C = np.array([[x1, x2] for x1, x2 in zip(np.ravel(A), np.ravel(B))])
    Z = clf.decision_function(C).reshape(A.shape)
    pl.contour(A, B, Z, [0.0], colors="k", linewidths=1, origin="lower")

    pl.axis("tight")
开发者ID:pandasasa,项目名称:lightning,代码行数:25,代码来源:plot_sparse_non_linear.py


示例9: scatter_from_csv

 def scatter_from_csv(self, filename, sand = 'sand', silt = 'silt', clay = 'clay', diameter = '', hue = '', tags = '', **kwargs):
     """Loads data from filename (expects csv format). Needs one header row with at least the columns {sand, silt, clay}. Can also plot two more variables for each point; specify the header value for columns to be plotted as diameter, hue. Can also add a text tag offset from each point; specify the header value for those tags.
     Note! text values (header entries, tag values ) need to be quoted to be recognized as text. """
     fh = file(filename, 'rU')
     soilrec = csv2rec(fh)
     count = 0
     if (sand in soilrec.dtype.names):
         count = count + 1
     if (silt in soilrec.dtype.names):
         count = count + 1
     if (clay in soilrec.dtype.names):
         count = count + 1
     if (count < 3):
         print "ERROR: need columns for sand, silt and clay identified in ', filename"
     locargs = {'s': None, 'c': None}
     for (col, key) in ((diameter, 's'), (hue, 'c')):
         col = col.lower()
         if (col != '') and (col in soilrec.dtype.names):
             locargs[key] = soilrec.field(col)
         else:
             print 'ERROR: did not find ', col, 'in ', filename
     for k in kwargs:
         locargs[k] = kwargs[k]
     values = zip(*[soilrec.field(sand), soilrec.field(clay), soilrec.field(silt)])
     print values
     (xs, ys) = self._toCart(values)
     p.scatter(xs, ys, label='_', **locargs)
     if (tags != ''):
         tags = tags.lower()
         for (x, y, tag) in zip(*[xs, ys, soilrec.field(tags)]):
             print x,
             print y,
             print tag
             p.text(x + 1, y + 1, tag, fontsize=12)
     fh.close()
开发者ID:btweinstein,项目名称:TernaryPlotPy,代码行数:35,代码来源:trianglegraph.py


示例10: plot

    def plot(self):
        f = pylab.figure(figsize=(8,4))
        co = [] #colors container
        for zScore, r in itertools.izip(self.zScores, self.log2Ratio):
            if zScore < self.pCut:
                if r > 0:
                    co.append(Colors().greenColor)
                elif r < 0:
                    co.append(Colors().redColor)
                else:
                    raise Exception
            else:
                co.append(Colors().blueColor)

        #print "Probability this is from a normal distribution: %.3e" %stats.normaltest(self.log2Ratio)[1]
        ax = f.add_subplot(121)
        pylab.axvline(self.meanLog2Ratio, color=Colors().redColor)
        pylab.axvspan(self.meanLog2Ratio-(2*self.stdLog2Ratio), 
                      self.meanLog2Ratio+(2*self.stdLog2Ratio), color=Colors().blueColor, alpha=0.2)
        his = pylab.hist(self.log2Ratio, bins=50, color=Colors().blueColor)
        pylab.xlabel("log2 Ratio %s/%s" %(self.sampleNames[1], self.sampleNames[0]))
        pylab.ylabel("Frequency")
        
        ax = f.add_subplot(122, aspect='equal')
        pylab.scatter(self.genes1, self.genes2, c=co, alpha=0.5)        
        pylab.ylabel("%s RPKM" %self.sampleNames[1])
        pylab.xlabel("%s RPKM" %self.sampleNames[0])
        pylab.yscale('log')
        pylab.xscale('log')
        pylab.tight_layout()
开发者ID:TorHou,项目名称:gscripts,代码行数:30,代码来源:rpkmZ.py


示例11: genderBoxplots

    def genderBoxplots(self, women, men, labels, path):
        data = [women.edition_count.values, men.edition_count.values]

        plt.figure()
        plt.boxplot(data)

        # mark the mean
        means = [np.mean(x) for x in data]
        print(means)

        plt.scatter(range(1, len(data) + 1), means, color="red", marker=">", s=20)
        plt.ylabel("num editions")
        plt.xticks(range(1, len(data) + 1), labels)
        plt.savefig(
            path + "/numeditions_gender_box_withOutlier" + self.pre + "-" + self.post + ".png", bbox_inches="tight"
        )

        plt.figure()
        plt.boxplot(data, sym="")
        # mark the mean
        means = [np.mean(x) for x in data]
        print(means)

        plt.scatter(range(1, len(data) + 1), means, color="red", marker=">", s=20)
        plt.ylabel("num editions")
        plt.xticks(range(1, len(data) + 1), labels)
        plt.savefig(path + "/numeditions_gender_box" + self.pre + "-" + self.post + ".png", bbox_inches="tight")
开发者ID:clauwag,项目名称:WikipediaGenderInequality,代码行数:27,代码来源:GlobalWikipediaPopularity.py


示例12: linearReg

def linearReg():
    from sklearn import datasets
    diabetes = datasets.load_diabetes()
    diabetes_X_train = diabetes.data[:-20]
    diabetes_X_test = diabetes.data[-20:]
    diabetes_y_train = diabetes.target[:-20]
    diabetes_y_test = diabetes.target[-20:]
    from sklearn import linear_model
    regr = linear_model.LinearRegression()
    regr.fit(diabetes_X_train, diabetes_y_train)
    print(regr.coef_)
    import numpy as np
    np.mean((regr.predict(diabetes_X_test) - diabetes_y_test) ** 2)
    regr.score(diabetes_X_test, diabetes_y_test)

    X = np.c_[.5, 1].T
    y = [.5, 1]
    test = np.c_[0, 2].T
    regr = linear_model.LinearRegression()

    import pylab as pl
    pl.figure()
    np.random.seed(0)
    for _ in range(6):
        this_X = .1 * np.random.normal(size=(2, 1)) + X
        regr.fit(this_X, y)
        pl.plot(test, regr.predict(test))
        pl.scatter(this_X, y, s=3)
开发者ID:avain,项目名称:machineLearning,代码行数:28,代码来源:snippy.py


示例13: plot_all

def plot_all(x, y):
	pca = PCA(n_components=2)
	new_x = pca.fit(x).transform(x)
	for i in range(0, len(new_x)):
		l_color = color_list[y[i]]
		pl.scatter(new_x[i, 0], new_x[i, 1], color=l_color)
	pl.show()
开发者ID:chaluemwut,项目名称:fselection,代码行数:7,代码来源:vmodel2.py


示例14: draw_cluster

 def draw_cluster(self):
     for station in self.cluster.stations:
         for detector in station.detectors:
             x, y = detector.get_xy_coordinates()
             plt.scatter(x, y, c='r', s=5, edgecolor='none')
         x, y, alpha = station.get_xyalpha_coordinates()
         plt.scatter(x, y, c='orange', s=10, edgecolor='none')
开发者ID:pombredanne,项目名称:sapphire,代码行数:7,代码来源:core_reconstruction.py


示例15: plot

def plot(n):
    h = heighway(n)
    x, y = [], []
    for z in h:
        x.append(z.real), y.append(z.imag)
    scatter(x, y)
    show()
开发者ID:genos,项目名称:Programming,代码行数:7,代码来源:dragon.py


示例16: test_regress_vary_na

def test_regress_vary_na(baselines, coeffs, nants=32, restrictChi=False):
    """
    This function runs many tests of the linear regression, varying the number 
    of antennae in the array. Again, the global signal is hard-coded to be 1.
    """
    for jj in n.arange(100):
        nas = n.arange(2, nants)
        gs_diff = n.zeros(len(nas))
        for ii, na in enumerate(nas):
            gs_recov, redchi, err = test_regress(baselines, coeffs, gs=1, n_sig=0.1, na=na, readFromFile=True)
            if restrictChi:
                if n.absolute(redchi - 1) < 0.1:
                    gs_diff[ii] = gs_recov - 1.0
                else:
                    gs_diff[ii] = None
            else:
                gs_diff[ii] = gs_recov - 1.0
        p.scatter(nas, gs_diff)
    p.xlabel("Number of antenna")
    p.ylabel("Difference between true and recovered global signal")
    # p.show()
    if restrictChi:
        p.savefig("./figures/gs_diff_vs_na_good_chi.pdf")
    else:
        p.savefig("./figures/gs_diff_vs_na.pdf")
    p.clf()
开发者ID:mkolopanis,项目名称:capo,代码行数:26,代码来源:global_sig.py


示例17: pair_plot

def pair_plot(data, savefile=None, display=True, **kwargs):
    chan = data.channels
    l = len(chan)
    figure = pylab.figure()
    pylab.subplot(l, l, 1)
    for i in range(l):
        for j in range(i + 1):
            pylab.subplot(l, l, i * l + j + 1)
            if i == j:
                pylab.hist(data[:, i], bins=200, histtype='stepfilled')
            else:
                pylab.scatter(data[:, i], data[:, j], **kwargs)

            if j == 0:
                pylab.ylabel(chan[i])
            if i == l - 1:
                pylab.xlabel(chan[j])

    if display:
        pylab.show()

    if savefile:
        pylab.savefig(savefile)

    return figure
开发者ID:whitews,项目名称:fcm,代码行数:25,代码来源:plot.py


示例18: test_regress_vary_bsln

def test_regress_vary_bsln(baselines, coeffs, nants=32, restrictChi=False):
    """
    This is the exact same function as test_regress_vary_na except that it 
    plots the number of baselines on the x axis instead of the number of 
    antennae.
    """
    for jj in n.arange(100):
        nas = n.arange(2, nants)
        gs_diff = n.zeros(len(nas))
        for ii, na in enumerate(nas):
            gs_recov, redchi, err = test_regress(baselines, coeffs, gs=1, n_sig=0.1, na=na, readFromFile=True)
            if restrictChi:
                if n.absolute(redchi - 1) < 0.1:
                    gs_diff[ii] = gs_recov - 1.0
                else:
                    gs_diff[ii] = None
            else:
                gs_diff[ii] = gs_recov - 1.0
        p.scatter(nas * (nas - 1) / 2, gs_diff)
    p.xlabel("Number of baselines")
    p.ylabel("Difference between true and recovered global signal")
    # p.show()
    if restrictChi:
        p.savefig("./figures/gs_diff_vs_bsln_good_chi.pdf")
    else:
        p.savefig("./figures/gs_diff_vs_bsln.pdf")
    p.clf()
开发者ID:mkolopanis,项目名称:capo,代码行数:27,代码来源:global_sig.py


示例19: plot_scatter

def plot_scatter(results, xvar='lat', yvar='max_CAPE'):
    plt.xlabel(xvar)
    plt.ylabel(yvar)

    for res in results:
        if res['max_CAPE'] != 0:
            plt.scatter(res[xvar], res[yvar])
开发者ID:markmuetz,项目名称:pam,代码行数:7,代码来源:pam.py


示例20: main

def main():
    args = sys.argv[1:]
    
    dataset_path = None
    if args and '-save' in args:
        try: dataset_path = args[args.index('-save') + 1]
        except: dataset_path = 'dataset.p'
        
    # Generate the dataset
    print "...Generating Dataset..."
    X1, Y1 = make_circles(n_samples=800, noise=0.07, factor=0.4)
    frac0 = len(np.where(Y1 == 0)[0]) / float(len(Y1))
    frac1 = len(np.where(Y1 == 1)[0]) / float(len(Y1))
    
    print "Percentage of '0' labels:", frac0
    print "Percentage of '1' labels:", frac1

    # (Optionally) save the dataset to DATASET_PATH
    if dataset_path:
        print "...Saving dataset to {0}...".format(dataset_path)
        pickle.dump((X1, Y1, frac0, frac1), open(dataset_path, 'wb'))

    # Plot the dataset
    print "...Showing dataset in new window..."
    pl.figure(figsize=(10, 8))
    pl.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95)

    pl.subplot(111)
    pl.title("Our Dataset: N=200, '0': {0} '1': {1} ".format(frac0, frac1), fontsize="large")

    pl.scatter(X1[:, 0], X1[:, 1], marker='o', c=Y1)

    pl.show()
    
    print "...Done."
开发者ID:ewestern,项目名称:machine_learning,代码行数:35,代码来源:generate_dataset.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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