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


Python pyplot.pcolormesh函数代码示例

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


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

示例1: plot_2d

def plot_2d(x, y, mean, variance, ei, slice_at, v1_name, v2_name):
    h_fig = pplt.figure(figsize=(20, 8), dpi=100)
    pplt.subplot(131)
    h_mean = pplt.pcolormesh(x, y,
                             mean.reshape(x.shape[0], y.shape[0]))
    pplt.colorbar(h_mean)
    slice_at_list = np.squeeze(np.asarray(slice_at)).tolist()
    slice_at_string = str(["%.2f" % member for member in slice_at_list])
    pplt.xlabel(r'$' + v1_name + '$')
    pplt.ylabel(r'$' + v2_name + '$')
    pplt.title(r'Mean, slice along $( ' + v1_name + ',' + v2_name + ')$ at ' +
               slice_at_string)

    pplt.subplot(132)
    h_var = pplt.pcolormesh(x, y, 2*np.sqrt(variance.reshape(x.shape[0],
                                                   y.shape[0])))
    pplt.colorbar(h_var)
    pplt.xlabel(r'$' + v1_name + '$')
    pplt.ylabel(r'$' + v2_name + '$')
    pplt.title(r'2*Stdev, slice along $( ' + v1_name + ',' + v2_name + ')$' )

    pplt.subplot(133)
    h_ei = pplt.pcolormesh(x, y, ei.reshape(x.shape[0], y.shape[0]))
    pplt.colorbar(h_var)
    pplt.xlabel(r'$' + v1_name + '$')
    pplt.ylabel(r'$' + v2_name + '$')
    pplt.title(r'EI, slice along $( ' + v1_name + ',' + v2_name + ')$')

    pplt.draw()
    return (h_fig, h_mean, h_var, h_ei)
开发者ID:jucor,项目名称:spearmint,代码行数:30,代码来源:spearmint-plot.py

示例2: Pcolor

def Pcolor(xs, ys, zs, pcolor=True, contour=False, **options):
    """Makes a pseudocolor plot.
    
    xs:
    ys:
    zs:
    pcolor: boolean, whether to make a pseudocolor plot
    contour: boolean, whether to make a contour plot
    options: keyword args passed to pyplot.pcolor and/or pyplot.contour
    """
    Underride(options, linewidth=3, cmap=matplotlib.cm.Blues)

    X, Y = np.meshgrid(xs, ys)
    Z = zs

    x_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
    axes = pyplot.gca()
    axes.xaxis.set_major_formatter(x_formatter)

    if pcolor:
        pyplot.pcolormesh(X, Y, Z, **options)

    if contour:
        cs = pyplot.contour(X, Y, Z, **options)
        pyplot.clabel(cs, inline=1, fontsize=10)
开发者ID:elephantzhai,项目名称:Learn,代码行数:25,代码来源:myplot.py

示例3: plt_data

def plt_data():
    t = [[0,1], [1,0], [1, 1], [0, 0]]
    t2 = [1, 1, 1, 0]
    X = np.array(t)
    Y = np.array(t2)

    h = .02  # step size in the mesh

    logreg = linear_model.LogisticRegression(C=1e5)

    # we create an instance of Neighbours Classifier and fit the data.
    logreg.fit(X, Y)
    # Plot the decision boundary. For that, we will assign a color to each
    # point in the mesh [x_min, m_max]x[y_min, y_max].
    x_min, x_max = X[:, 0].min() - .5, X[:, 0].max() + .5
    y_min, y_max = X[:, 1].min() - .5, X[:, 1].max() + .5
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
    Z = logreg.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    plt.figure(1, figsize=(4, 3))
    plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)

    # Plot also the training points
    plt.scatter(X[:, 0], X[:, 1], c=Y, edgecolors='k', cmap=plt.cm.Paired)
    plt.xlabel('Sepal length')
    plt.ylabel('Sepal width')

    plt.xlim(xx.min(), xx.max())
    plt.ylim(yy.min(), yy.max())
    plt.xticks(())
    plt.yticks(())

    plt.show()
开发者ID:robsonfgomes,项目名称:Redes-Neurais,代码行数:35,代码来源:main.py

示例4: test_unimodality_of_GEV

    def test_unimodality_of_GEV(self):
        x0 = 1500

        mu = 1000
        data = np.array([x0])

        ksi = np.arange(-2, 2, 0.01)
        sigma = np.arange(10, 8000, 10)

        n_ksi = len(ksi)
        n_sigma = len(sigma)

        z = np.zeros((n_ksi, n_sigma))

        for i, the_ksi in enumerate(ksi):
            for j, the_sigma in enumerate(sigma):
                z[i, j] = gevfit.objective_function_stationary_high([the_sigma, mu, the_ksi], data)


        sigma, ksi = np.meshgrid(sigma, ksi)
        z = np.ma.masked_where(z == gevfit.BIG_NUM, z)
        z = np.ma.masked_where(z > 9, z)

        plt.figure()
        plt.pcolormesh(ksi, sigma, z)
        plt.colorbar()
        plt.xlabel('$\\xi$')
        plt.ylabel('$\\sigma$')
        plt.title('$\\mu = %.1f, x = %.1f$' % (mu, x0))

        plt.show()


        pass
开发者ID:guziy,项目名称:GevFit,代码行数:34,代码来源:test_gevfit.py

示例5: prettyPicture

def prettyPicture(clf, X_test, y_test):
    x_min = 0.0;
    x_max = 1.0
    y_min = 0.0;
    y_max = 1.0

    # Plot the decision boundary. For that, we will assign a color to each
    # point in the mesh [x_min, m_max]x[y_min, y_max].
    h = .01  # step size in the mesh
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
    Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    plt.xlim(xx.min(), xx.max())
    plt.ylim(yy.min(), yy.max())

    plt.pcolormesh(xx, yy, Z)

    # Plot also the test points
    grade_sig = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii] == 0]
    bumpy_sig = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii] == 0]
    grade_bkg = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii] == 1]
    bumpy_bkg = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii] == 1]

    plt.scatter(grade_sig, bumpy_sig, color="b", label="fast")
    plt.scatter(grade_bkg, bumpy_bkg, color="r", label="slow")
    plt.legend()
    plt.xlabel("bumpiness")
    plt.ylabel("grade")

    plt.savefig("test.png")
开发者ID:mukhan85,项目名称:Courses,代码行数:32,代码来源:visual.py

示例6: visualize

    def visualize(self, output_file, width=2, show_charts=False):
        X = self.X

        # Create a grid of points
        x_min, x_max = min(X[:, 0] - width), max(X[:, 0] + width)
        y_min, y_max = min(X[:, 1] - width), max(X[:, 1] + width)
        xx,yy = np.meshgrid(np.arange(x_min, x_max, .05), np.arange(y_min,
            y_max, .05))

        # Flatten the grid so the values match spec for self.predict
        xx_flat = xx.flatten()
        yy_flat = yy.flatten()
        X_topredict = np.vstack((xx_flat,yy_flat)).T

        # Get the class predictions
        Y_hat = self.predict(X_topredict)
        Y_hat = Y_hat.reshape((xx.shape[0], xx.shape[1]))
        
        cMap = c.ListedColormap(['r','b','g'])

        # Visualize them.
        plt.figure()
        plt.pcolormesh(xx,yy,Y_hat, cmap=cMap)
        plt.scatter(X[:, 0], X[:, 1], c=self.C, cmap=cMap)
        plt.savefig(output_file)
        if show_charts:
            plt.show()
开发者ID:lukeam2929,项目名称:CS181-Homework-2016,代码行数:27,代码来源:LogisticRegression_LM.py

示例7: plotmaptime

def plotmaptime():
    pcolormesh(yoko, time*1e6, absolute(Magcom))
    title("Reflection vs flux \n and time (1 us pulse) at 4.46 GHz")
    xlabel("Flux (V)")
    ylabel("Time (us)")
    #ylim(0, 1.5)
    colorbar()
开发者ID:priyanka27s,项目名称:TA_software,代码行数:7,代码来源:D1006_refl_time_domain.py

示例8: plot_spectrogram

def plot_spectrogram(raw_data, nfft, fs, channel_bottom, print_frequency_graph):
    data_shape = raw_data.shape

    print("Generating spectrogram...")
    plt_num = 1
    plt.clf()
    plt.figure(1)

    channel_data = []
    for i in range(0, data_shape[1]):
        plt.subplot(8, 2, plt_num)

        f, t, Sxx = signal.spectrogram(x=raw_data[:, i], nfft=nfft, fs=fs, noverlap=127, nperseg=128,
                                       scaling='density')  # returns PSD power per Hz
        plt.pcolormesh(t, f, Sxx)

        plt.xlabel('Time (sec)')
        plt.ylabel('Frequency (Hz)')
        plt.title('Channel %s' % (i + channel_bottom))
        plt_num += 1
        channel_data.append([f, t, Sxx])
        print("\tChannel %d spectrogram generated" % i)
    if print_frequency_graph:
        plt.show()
    return channel_data
开发者ID:sweetrabh,项目名称:testeeg,代码行数:25,代码来源:main.py

示例9: test_pcolormesh_global_with_wrap3

def test_pcolormesh_global_with_wrap3():
    nx, ny = 33, 17
    xbnds = np.linspace(-1.875, 358.125, nx, endpoint=True)
    ybnds = np.linspace(91.25, -91.25, ny, endpoint=True)
    xbnds, ybnds = np.meshgrid(xbnds, ybnds)

    data = np.exp(np.sin(np.deg2rad(xbnds)) + np.cos(np.deg2rad(ybnds)))

    # this step is not necessary, but makes the plot even harder to do (i.e.
    # it really puts cartopy through its paces)
    ybnds = np.append(ybnds, ybnds[:, 1:2], axis=1)
    xbnds = np.append(xbnds, xbnds[:, 1:2] + 360, axis=1)
    data = np.ma.concatenate([data, data[:, 0:1]], axis=1)

    data = data[:-1, :-1]
    data = np.ma.masked_greater(data, 2.6)

    ax = plt.subplot(211, projection=ccrs.PlateCarree(-45))
    c = plt.pcolormesh(xbnds, ybnds, data, transform=ccrs.PlateCarree())
    assert c._wrapped_collection_fix is not None, \
        'No pcolormesh wrapping was done when it should have been.'

    ax.coastlines()
    ax.set_global()  # make sure everything is visible

    ax = plt.subplot(212, projection=ccrs.PlateCarree(-1.87499952))
    plt.pcolormesh(xbnds, ybnds, data, transform=ccrs.PlateCarree())
    ax.coastlines()
    ax.set_global()  # make sure everything is visible
开发者ID:bblay,项目名称:cartopy,代码行数:29,代码来源:test_mpl_integration.py

示例10: Picture

def Picture(clf, X_test, y_test):
    x_min = 200.0
    x_max = 1000.0
    y_min = 600.0
    y_max = 2500.0

    # Plot the decision boundary. For that, we will assign a color to each
    # point in the mesh [x_min, m_max]x[y_min, y_max].
    h = 1  # step size in the mesh
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
    Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])

    # Put the result into a color plot
    Z = Z.reshape(xx.shape)
    plt.xlim(xx.min(), xx.max())
    plt.ylim(yy.min(), yy.max())

    plt.pcolormesh(xx, yy, Z, cmap=pl.cm.seismic)

    # Plot also the test points
    x1 = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii] == 0]
    y1 = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii] == 0]
    x2 = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii] == 1]
    y2 = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii] == 1]
    x3 = [X_test[ii][0] for ii in range(0, len(X_test)) if y_test[ii] == 2]
    y3 = [X_test[ii][1] for ii in range(0, len(X_test)) if y_test[ii] == 2]

    plt.scatter(x1, y1, color="b", label="class1")
    plt.scatter(x2, y2, color="r", label="class2")
    plt.scatter(x3, y3, color="g", label="class3")
    plt.legend()
    plt.xlabel("x")
    plt.ylabel("y")

    plt.savefig("testrf.png")
开发者ID:SamriddhiJain,项目名称:rforest_exp,代码行数:35,代码来源:class_vis.py

示例11: train_Quasi_linear_SVM

def train_Quasi_linear_SVM():
	from sklearn import svm
	clf = svm.SVC(kernel=get_KernelMatrix)
	X_train = np.r_[X1,X2]
	Y_train = np.r_[Y1,Y2]
	scatter(X[:,0],X[:,1],c='g')
	clf.fit(X_train, Y_train)

	y_pred = clf.predict(X_test)

	#scatter(X_test, y_pred)

	clf = svm.SVC(kernel=get_KernelMatrix)
	clf.fit(X, y)
	clf.predict(X_test1)

	# Plot the decision boundary. For that, we will assign a color to each
	# point in the mesh [x_min, m_max]x[y_min, y_max].
	h = 0.05
	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.arange(x_min, x_max, h), np.arange(y_min, y_max, h))
	Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])

	# Put the result into a color plot
	Z = Z.reshape(xx.shape)
	plt.pcolormesh(xx, yy, Z, cmap=plt.cm.Paired)

	# Plot also the training points
	plt.scatter(X_train[:, 0], X_train[:, 1], c=Y_train)
	plt.title('2-Class classification using Support Vector Machine with quasi-linear kernel')
	plt.axis('tight')
	plt.legend([Y_train[0], Y_train[-1]], ['negtive sample', 'postive sample'])
	plt.show()
开发者ID:xuanzhao,项目名称:master_degree,代码行数:34,代码来源:DecisionTreeReg_constant_sin.py

示例12: plotter

def plotter(filename, xmin=0, xmax=300, Nx=2000,
            ymin=0, ymax=1, Ny=2000, sigma_x=3, sigma_y=0.01):
    root = '/home/cyneo/Work/Scans/Processed Data/Extracted CSV/'
    file1 = os.path.abspath(root + filename + '.csv')
    nx = linspace(xmin, xmax, Nx)
    ny = linspace(ymin, ymax, Ny)
    x, y = meshgrid(nx, ny)
    mastermesh = []
    with open(file1, 'r', encoding='utf8') as filein:
        file_reader = csv.reader(filein)
        next(file_reader)

        for word, frequency, inhubness, outhubness in file_reader:
            # want to feed the values into the center points
            if mastermesh == []:
                mastermesh = dgaussian(x, y, float(frequency),
                                       float(outhubness), sigma_x, sigma_y)
            else:
                mastermesh += dgaussian(x, y, float(frequency),
                                        float(outhubness), sigma_x, sigma_y)

    for x in range(len(mastermesh)):
        for y in range(len(mastermesh[x])):
            mastermesh[x, y] = np.log(mastermesh[x, y]+1)

    x, y = meshgrid(nx, ny)
    plt.pcolormesh(x, y, mastermesh)
    plt.show()
    outfile = os.path.abspath(root + filename + ' Array')
    np.save(outfile, mastermesh)
开发者ID:cyneo,项目名称:feminism,代码行数:30,代码来源:gaussian.py

示例13: plot_basins

def plot_basins(f, Df, roots, xmin, xmax, ymin, ymax, numpoints=100, iters=15, colormap='brg'):
    '''Plot the basins of attraction of f.
    
    INPUTS:
    f       - A function handle. Should represent a function 
            from C to C.
    Df      - A function handle. Should be the derivative of f.
    roots   - An array of the zeros of f.
    xmin, xmax, ymin, ymax - Scalars that define the domain 
            for the plot.
    numpoints - A scalar that determines the resolution of 
            the plot. Defaults to 100.
    iters   - Number of times to iterate Newton's method. 
            Defaults to 15.
    colormap - A colormap to use in the plot. Defaults to 'brg'.    
    '''
    xreal = np.linspace(xmin, xmax, numpoints)
    ximag = np.linspace(ymin, ymax, numpoints)
    Xreal, Ximag = np.meshgrid(xreal, ximag)
    xold = Xreal+1j*Ximag
    n = 0
    while n <= iters:
        xnew = xold - f(xold)/Df(xold)
        xold = xnew
        n += 1 

    converged_to = np.empty_like(xnew)
    for i in xrange(xnew.shape[0]):
        for j in xrange(xnew.shape[1]):
            root = np.abs(roots-xnew[i,j]).argmin()
            converged_to[i,j] = root

    plt.pcolormesh(Xreal, Ximag, converged_to, cmap=colormap)
开发者ID:davidreber,项目名称:Labs,代码行数:33,代码来源:solutions.py

示例14: pcolorRandom

def pcolorRandom():
    "Makes a pcolormesh plot of randomly generated data pts."
    # make up some randomly distributed data
    npts = 100
    x = uniform(-3, 3, npts)
    y = uniform(-3, 3, npts)
    z = x * N.exp(-x ** 2 - y ** 2)

    # define grid.
    xi = N.arange(-3.1, 3.1, 0.05)
    yi = N.arange(-3.1, 3.1, 0.05)

    # grid the data.
    zi = griddata(x, y, z, xi, yi)

    # contour the gridded data, plotting dots at the randomly spaced data points.
    plt.pcolormesh(xi, yi, zi)	
    #CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
    #CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
    plt.colorbar() # draw colorbar

    # plot data points.
    plt.scatter(x, y, marker='o', c='b', s=5)
    plt.xlim(-3, 3)
    plt.ylim(-3, 3)
    plt.title('griddata test (%d points)' % npts)
    plt.show()
开发者ID:scattering,项目名称:dataflow,代码行数:27,代码来源:regular_gridding.py

示例15: plot_eta

def plot_eta(pT_lower_cut):

	properties_reco = [parse_file("/home/aashish/pythia_reco.dat", pT_lower_cut=pT_lower_cut), parse_file("/home/aashish/herwig_reco.dat", pT_lower_cut=pT_lower_cut), parse_file("/home/aashish/sherpa_reco.dat", pT_lower_cut=pT_lower_cut)]
	properties_truth = [parse_file("/home/aashish/pythia_truth.dat", pT_lower_cut=pT_lower_cut), parse_file("/home/aashish/herwig_truth.dat", pT_lower_cut=pT_lower_cut), parse_file("/home/aashish/sherpa_truth.dat", pT_lower_cut=pT_lower_cut)]
	labels = ["pythia", "herwig", "sherpa"]

	for prop_reco, prop_truth, label in zip(properties_reco, properties_truth, labels):
	
		x = prop_truth['hardest_eta']
		y = prop_reco['hardest_eta']

		H, xedges, yedges = np.histogram2d(x, y, bins=200, normed=1 )

		H = np.rot90(H)
		H = np.flipud(H)

		Hmasked = np.ma.masked_where(H == 0, H) # Mask pixels with a value of zero

		plt.pcolormesh(xedges,yedges, Hmasked)

		cbar = plt.colorbar()
		cbar.ax.set_ylabel('Counts')

		plt.xlim(0, 3)
		plt.ylim(0, 3)

		plt.xlabel('Truth $\eta$', fontsize=50, labelpad=75)
		plt.ylabel('Reco $\eta$', fontsize=50, labelpad=75)

		plt.gcf().set_size_inches(30, 30, forward=1)
		plt.gcf().set_snap(True)

		plt.savefig("plots/With MC/2D/eta_" + label + ".pdf")

		plt.clf()
开发者ID:tripatheea,项目名称:MODAnalyzer,代码行数:35,代码来源:plots_truth_reco.py


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