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


Python pylab.scatter方法代码示例

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


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

示例1: test_lines_dists

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def test_lines_dists():
    import pylab
    ax = pylab.gca()

    xs, ys = (0,30), (20,150)
    pylab.plot(xs, ys)
    points = list(zip(xs, ys))
    p0, p1 = points

    xs, ys = (0,0,20,30), (100,150,30,200)
    pylab.scatter(xs, ys)

    dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
    dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
    for x, y, d in zip(xs, ys, dist):
        c = Circle((x, y), d, fill=0)
        ax.add_patch(c)

    pylab.xlim(-200, 200)
    pylab.ylim(-200, 200)
    pylab.show() 
开发者ID:Sterncat,项目名称:opticspy,代码行数:23,代码来源:proj3d.py

示例2: test_proj

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def test_proj():
    import pylab
    M = test_proj_make_M()

    ts = ['%d' % i for i in [0,1,2,3,0,4,5,6,7,4]]
    xs, ys, zs = [0,1,1,0,0, 0,1,1,0,0], [0,0,1,1,0, 0,0,1,1,0], \
            [0,0,0,0,0, 1,1,1,1,1]
    xs, ys, zs = [np.array(v)*300 for v in (xs, ys, zs)]
    #
    test_proj_draw_axes(M, s=400)
    txs, tys, tzs = proj_transform(xs, ys, zs, M)
    ixs, iys, izs = inv_transform(txs, tys, tzs, M)

    pylab.scatter(txs, tys, c=tzs)
    pylab.plot(txs, tys, c='r')
    for x, y, t in zip(txs, tys, ts):
        pylab.text(x, y, t)

    pylab.xlim(-0.2, 0.2)
    pylab.ylim(-0.2, 0.2)

    pylab.show() 
开发者ID:Sterncat,项目名称:opticspy,代码行数:24,代码来源:proj3d.py

示例3: test_lines_dists

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def test_lines_dists():
    import pylab
    ax = pylab.gca()

    xs, ys = (0,30), (20,150)
    pylab.plot(xs, ys)
    points = zip(xs, ys)
    p0, p1 = points

    xs, ys = (0,0,20,30), (100,150,30,200)
    pylab.scatter(xs, ys)

    dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
    dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
    for x, y, d in zip(xs, ys, dist):
        c = Circle((x, y), d, fill=0)
        ax.add_patch(c)

    pylab.xlim(-200, 200)
    pylab.ylim(-200, 200)
    pylab.show() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:proj3d.py

示例4: polyfitting

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def polyfitting():
    '''
    helper function to play around with polyfit from:
    http://www.wired.com/2011/01/linear-regression-with-pylab/
    '''
    x = [0.2, 1.3, 2.1, 2.9, 3.3]
    y = [3.3, 3.9, 4.8, 5.5, 6.9]
    slope, intercept = pylab.polyfit(x, y, 1)
    print 'slope:', slope, 'intercept:', intercept

    yp = pylab.polyval([slope, intercept], x)
    pylab.plot(x, yp)
    pylab.scatter(x, y)
    pylab.show()

#polyfitting() 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:18,代码来源:homework1.py

示例5: plot_question7

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def plot_question7():
    '''
    graph of total resources generated as a function of time,
    for upgrade_cost_increment == 1
    '''
    data = resources_vs_time(1.0, 50)
    time = [item[0] for item in data]
    resource = [item[1] for item in data]
    a, b, c = pylab.polyfit(time, resource, 2)
    print 'polyfit with argument \'2\' fits the data, thus the degree of the polynomial is 2 (quadratic)'

    # plot in pylab on logarithmic scale (total resources over time for upgrade growth 0.0)
    #pylab.loglog(time, resource, 'o')

    # plot fitting function
    yp = pylab.polyval([a, b, c], time)
    pylab.plot(time, yp)
    pylab.scatter(time, resource)
    pylab.title('Silly Homework, Question 7')
    pylab.legend(('Resources for increment 1', 'Fitting function' + ', slope: ' + str(a)))
    pylab.xlabel('Current Time')
    pylab.ylabel('Total Resources Generated')
    pylab.grid()
    pylab.show() 
开发者ID:chubbypanda,项目名称:principles-of-computing,代码行数:26,代码来源:homework1.py

示例6: plot_iris_knn

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def plot_iris_knn():
    iris = datasets.load_iris()
    X = iris.data[:, :2]  # we only take the first two features. We could
                        # avoid this ugly slicing by using a two-dim dataset
    y = iris.target

    knn = neighbors.KNeighborsClassifier(n_neighbors=3)
    knn.fit(X, y)

    x_min, x_max = X[:, 0].min() - .1, X[:, 0].max() + .1
    y_min, y_max = X[:, 1].min() - .1, X[:, 1].max() + .1
    xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100),
                         np.linspace(y_min, y_max, 100))
    Z = knn.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    pl.figure()
    pl.pcolormesh(xx, yy, Z, cmap=cmap_light)

    # Plot also the training points
    pl.scatter(X[:, 0], X[:, 1], c=y, cmap=cmap_bold)
    pl.xlabel('sepal length (cm)')
    pl.ylabel('sepal width (cm)')
    pl.axis('tight') 
开发者ID:jakevdp,项目名称:sklearn_pydata2015,代码行数:27,代码来源:helpers.py

示例7: __init__

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def __init__(self, table, lens='mds', metric='correlation', precomputed=False, **kwargs):
        """
        Initializes the class by providing the mapper input table generated by Preprocess.save(). The parameter 'metric'
        specifies the metric distance to be used ('correlation', 'euclidean' or 'neighbor'). The parameter 'lens'
        specifies the dimensional reduction algorithm to be used ('mds' or 'pca'). The rest of the arguments are
        passed directly to sklearn.manifold.MDS or sklearn.decomposition.PCA. It plots the low-dimensional projection
        of the data.
        """
        self.df = pandas.read_table(table + '.mapper.tsv')
        if lens == 'neighbor':
            self.lens_data_mds = sakmapper.apply_lens(self.df, lens=lens, **kwargs)
        elif lens == 'mds':
            if precomputed:
                self.lens_data_mds = sakmapper.apply_lens(self.df, lens=lens, metric=metric,
                                                          dissimilarity='precomputed', **kwargs)
            else:
                self.lens_data_mds = sakmapper.apply_lens(self.df, lens=lens, metric=metric, **kwargs)
        else:
            self.lens_data_mds = sakmapper.apply_lens(self.df, lens=lens, **kwargs)
        pylab.figure()
        pylab.scatter(numpy.array(self.lens_data_mds)[:, 0], numpy.array(self.lens_data_mds)[:, 1], s=10, alpha=0.7)
        pylab.show() 
开发者ID:CamaraLab,项目名称:scTDA,代码行数:24,代码来源:main.py

示例8: plot_CDR_correlation

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def plot_CDR_correlation(self, doplot=True):
        """
        Displays correlation between sampling time points and CDR. It returns the two
        parameters of the linear fit, Pearson's r, p-value and standard error. If optional argument 'doplot' is
        False, the plot is not displayed.
        """
        pel2, tol = self.get_gene(self.rootlane, ignore_log=True)
        pel = numpy.array([pel2[m] for m in self.pl])*tol
        dr2 = self.get_gene('_CDR')[0]
        dr = numpy.array([dr2[m] for m in self.pl])
        po = scipy.stats.linregress(pel, dr)
        if doplot:
            pylab.scatter(pel, dr, s=9.0, alpha=0.7, c='r')
            pylab.xlim(min(pel), max(pel))
            pylab.ylim(0, max(dr)*1.1)
            pylab.xlabel(self.rootlane)
            pylab.ylabel('CDR')
            xk = pylab.linspace(min(pel), max(pel), 50)
            pylab.plot(xk, po[1]+po[0]*xk, 'k--', linewidth=2.0)
            pylab.show()
        return po 
开发者ID:CamaraLab,项目名称:scTDA,代码行数:23,代码来源:main.py

示例9: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def plot(t, plots, shot_ind):
    n = len(plots)

    for i in range(0,n):
        label, data = plots[i]

        plt = py.subplot(n, 1, i+1)
        plt.tick_params(labelsize=8)
        py.grid()
        py.xlim([t[0], t[-1]])
        py.ylabel(label)

        py.plot(t, data, 'k-')
        py.scatter(t[shot_ind], data[shot_ind], marker='*', c='g')

    py.xlabel("Time")
    py.show()
    py.close() 
开发者ID:sealneaward,项目名称:nba-movement-data,代码行数:20,代码来源:fix_shot_times.py

示例10: coinc_timeseries_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def coinc_timeseries_plot(coinc_file, start, end):
    fig = pylab.figure()
    f = h5py.File(coinc_file, 'r')

    stat1 = f['foreground/stat1']
    stat2 = f['foreground/stat2']
    time1 = f['foreground/time1']
    time2 = f['foreground/time2']
    ifo1 = f.attrs['detector_1']
    ifo2 = f.attrs['detector_2']

    pylab.scatter(time1, stat1, label=ifo1, color=ifo_color[ifo1])
    pylab.scatter(time2, stat2, label=ifo2, color=ifo_color[ifo2])

    fmt = '.12g'
    mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
    pylab.legend()
    pylab.xlabel('Time (s)')
    pylab.ylabel('NewSNR')
    pylab.grid()
    return mpld3.fig_to_html(fig) 
开发者ID:gwastro,项目名称:pycbc,代码行数:23,代码来源:followup.py

示例11: trigger_timeseries_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def trigger_timeseries_plot(file_list, ifos, start, end):

    fig = pylab.figure()
    for ifo in ifos:
        trigs = columns_from_file_list(file_list,
                                       ['snr', 'end_time'],
                                       ifo, start, end)
        print(trigs)
        pylab.scatter(trigs['end_time'], trigs['snr'], label=ifo,
                      color=ifo_color[ifo])

        fmt = '.12g'
        mpld3.plugins.connect(fig, mpld3.plugins.MousePosition(fmt=fmt))
    pylab.legend()
    pylab.xlabel('Time (s)')
    pylab.ylabel('SNR')
    pylab.grid()
    return mpld3.fig_to_html(fig) 
开发者ID:gwastro,项目名称:pycbc,代码行数:20,代码来源:followup.py

示例12: plot_facade_cuts

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
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) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:37,代码来源:megafacade.py

示例13: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def plot(Y, labels):
    pylab.scatter(Y[:, 0], Y[:, 1], s=30, c=labels, cmap=colors, linewidth=0)
    pylab.show() 
开发者ID:paulorauber,项目名称:thesne,代码行数:5,代码来源:plot.py

示例14: plot_polynomial_regression

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
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:jakevdp,项目名称:sklearn_pydata2015,代码行数:35,代码来源:helpers.py

示例15: test_kmeans

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import scatter [as 别名]
def test_kmeans(K=5):
    """Test k-means with the synthetic data."""
    X = XMeans.generate_2d_data(K=4)
    wX = vq.whiten(X)
    dic, dist = vq.kmeans(wX, K, iter=100)

    plt.scatter(wX[:, 0], wX[:, 1])
    plt.scatter(dic[:, 0], dic[:, 1], color="m")
    plt.show() 
开发者ID:urinieto,项目名称:msaf,代码行数:11,代码来源:xmeans.py


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