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


Python pyplot.grid函数代码示例

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


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

示例1: plotaBarra

def plotaBarra(nEntradas, nSaidas):
	n_groups = 2

	means_men = (nEntradas, nSaidas)

	fig, ax = plt.subplots()

	index = np.arange(n_groups)
	bar_width = 0.15

	opacity = 0.4

	rects1 = plt.bar(index, means_men,  bar_width, alpha=opacity, color='b')

	#plt.xlabel('Tipo de passagem')
	plt.ylabel(u'Valor absoluto', size=20)
	plt.title(u'Número de passagens', size=20)
	plt.xticks(index + bar_width/2, ('Entradas', u'Saídas'), size=16)
	plt.legend()
	plt.grid(True)
	plt.axis((0, 2, 0, nSaidas + nEntradas + 1))		

	plt.tight_layout()
	#plt.show()
	plt.ylim(0,nEntradas + nSaidas + 1)
	plt.savefig('grafico.png')
开发者ID:leo-alves-melo,项目名称:contador_online,代码行数:26,代码来源:recebe_contagem_e_manda_html_local.py

示例2: _plot

    def _plot(self,names,title,style,when=0,showLegend=True):
        if isinstance(names,str):
            names = [names]
        assert isinstance(names,list)

        legend = []
        for name in names:
            assert isinstance(name,str)
            legend.append(name)

            # if it's a differential state
            if name in self.xNames:
                index = self.xNames.index(name)
                ys = np.squeeze(self._log['x'])[:,index]
                ts = np.arange(len(ys))*self.Ts
                plt.plot(ts,ys,style)
                
            if name in self.outputNames:
                index = self.outputNames.index(name)
                ys = np.squeeze(self._log['outputs'][name])
                ts = np.arange(len(ys))*self.Ts
                plt.plot(ts,ys,style)

        if title is not None:
            assert isinstance(title,str), "title must be a string"
            plt.title(title)
        plt.xlabel('time [s]')
        if showLegend is True:
            plt.legend(legend)
        plt.grid()
开发者ID:jgillis,项目名称:rawesome,代码行数:30,代码来源:mpc_mhe_utils.py

示例3: plotTestData

def plotTestData(tree):
	plt.figure()
	plt.axis([0,1,0,1])
	plt.xlabel("X axis")
	plt.ylabel("Y axis")
	plt.title("Green: Class1, Red: Class2, Blue: Class3, Yellow: Class4")
	for value in class1:
		plt.plot(value[0],value[1],'go')
	plt.hold(True)
	for value in class2:
		plt.plot(value[0],value[1],'ro')
	plt.hold(True)
	for value in class3:
		plt.plot(value[0],value[1],'bo')
	plt.hold(True)
	for value in class4:
		plt.plot(value[0],value[1],'yo')
	plotRegion(tree)
	for value in classPlot1:
		plt.plot(value[0],value[1],'g.',ms=3.0)
	plt.hold(True)
	for value in classPlot2:
		plt.plot(value[0],value[1],'r.', ms=3.0)
	plt.hold(True)
	for value in classPlot3:
		plt.plot(value[0],value[1],'b.', ms=3.0)
	plt.hold(True)
	for value in classPlot4:
		plt.plot(value[0],value[1],'y.', ms=3.0)
	plt.grid(True)
	plt.show()
开发者ID:swatibhartiya,项目名称:Metal-Scrap-Sorter,代码行数:31,代码来源:executeDT.py

示例4: mlr_val_ridge

def mlr_val_ridge( RM, yE, rate = 2, more_train = True, center = None, alpha = 0.5, disp = True, graph = True):
	"""
	Validation is peformed as much as the given ratio.
	"""
	RMt, yEt, RMv, yEv = jchem.get_valid_mode_data( RM, yE, rate = rate, more_train = more_train, center = center)

	print("Ridge: alpha = {}".format( alpha))
	clf = linear_model.Ridge( alpha = alpha)	
	clf.fit( RMt, yEt)

	print('Weight value')
	#print clf.coef_.flatten()
	plt.plot( clf.coef_.flatten())
	plt.grid()
	plt.xlabel('Tap')
	plt.ylabel('Weight')
	plt.title('Linear Regression Weights')
	plt.show()

	print('Training result')
	mlr_show( clf, RMt, yEt, disp = disp, graph = graph)

	print('Validation result')
	r_sqr, RMSE = mlr_show( clf, RMv, yEv, disp = disp, graph = graph)

	return r_sqr, RMSE
开发者ID:jskDr,项目名称:jamespy_py3,代码行数:26,代码来源:jutil.py

示例5: mlr_val_vseq_MMSE

def mlr_val_vseq_MMSE( RM, yE, v_seq, alpha = .5, disp = True, graph = True):
	"""
	Validation is peformed using vseq indexed values.
	"""
	org_seq = list(range( len( yE)))
	t_seq = [x for x in org_seq if x not in v_seq]

	RMt, yEt = RM[ t_seq, :], yE[ t_seq, 0]
	RMv, yEv = RM[ v_seq, :], yE[ v_seq, 0]

	w, RMt_1 = mmse_with_bias( RMt, yEt)
	yEt_c = RMt_1*w

	print('Weight values')
	#print clf.coef_.flatten()
	plt.plot( w.A1)
	plt.grid()
	plt.xlabel('Tap')
	plt.ylabel('Weight')
	plt.title('Linear Regression Weights')
	plt.show()

	RMv_1 = add_bias_xM( RMv)
	yEv_c = RMv_1*w

	if disp: print('Training result')
	regress_show( yEt, yEt_c, disp = disp, graph = graph)

	if disp: print('Validation result')
	r_sqr, RMSE = regress_show( yEv, yEv_c, disp = disp, graph = graph)

	#if r_sqr < 0:
	#	print 'v_seq:', v_seq, '--> r_sqr = ', r_sqr

	return r_sqr, RMSE	
开发者ID:jskDr,项目名称:jamespy_py3,代码行数:35,代码来源:jutil.py

示例6: plotFFT

	def plotFFT(self):
	# Generates plot of the FFT output. To view, run plotFFT.py in a separate terminal
		figure1 = plt.figure(num= None, figsize=(12,12), dpi=80, facecolor='w', edgecolor='w')
		plot1 = figure1.add_subplot(111)
		line1, = plot1.plot( np.arange(0,512,0.5), np.zeros(1024), 'g-')
		plt.xlabel('freq (MHz)',fontsize = 12)
		plt.ylabel('Amplitude',fontsize = 12)
		plt.title('Pre-mixer FFT',fontsize = 12)
		plt.xticks(np.arange(0,512,50))
		plt.xlim((0,512))
		plt.grid()
		plt.show(block = False)
		count = 0 
		stop = 1.0e6
		while(count < stop):
			overflow = np.fromstring(self.fpga.read('overflow', 4), dtype = '>B')
			print overflow
			self.fpga.write_int('fft_snap_ctrl',0)
			self.fpga.write_int('fft_snap_ctrl',1)
			fft_snap = (np.fromstring(self.fpga.read('fft_snap_bram',(2**9)*8),dtype='>i2')).astype('float')
			I0 = fft_snap[0::4]
			Q0 = fft_snap[1::4]
			I1 = fft_snap[2::4]
			Q1 = fft_snap[3::4]
			mag0 = np.sqrt(I0**2 + Q0**2)
			mag1 = np.sqrt(I1**2 + Q1**2)
			fft_mags = np.hstack(zip(mag0,mag1))
			plt.ylim((0,np.max(fft_mags) + 300.))
			line1.set_ydata((fft_mags))
			plt.draw()
			count += 1
开发者ID:braddober,项目名称:blastfirmware,代码行数:31,代码来源:blastfirmware_dirfile.py

示例7: make_let_im

def make_let_im(let_file, dim = 16, y_lo = 70, y_hi = 220, x_lo = 10, x_hi = 200, edge_pix = 150, plot_let = False):

    letter = mpimg.imread(let_file)

    letter = letter[y_lo:y_hi, x_lo:x_hi, 0]
    for i in range(letter.shape[1]):
        if letter[0:edge_pix, i].any() == 0:   # here is to remove the edge
            letter[0:edge_pix, i] = 1
    
    plt.imshow(letter, cmap='gray')
    plt.grid('off')
    plt.show()
        
    x = np.arange(letter.shape[1])
    y = np.arange(letter.shape[0])

    f2d = interp2d(x, y, letter)

    x_new = np.linspace(0, letter.shape[1], dim)    # dim = 16
    y_new = np.linspace(0, letter.shape[0], dim)

    letter_new = f2d(x_new, y_new)
    letter_new -= np.mean(letter_new)
    
    if plot_let: 
        plt.imshow(letter_new, cmap = 'gray')
        plt.grid('off')
        plt.show()
        
    letter_flat = letter_new.flatten()   # letter_flat is a 1-dimensional array containing 256 elements
    
    return letter_new, letter_flat
开发者ID:COMPPHYS-WGAO,项目名称:comp-phys,代码行数:32,代码来源:pca_letters.py

示例8: makePlot

def makePlot(
                k,
                counts,
                yaxis=[],
                width=0.8,
                figsize=[14.0,8.0],
                title="",
                ylabel='tmpylabel',
                xlabel='tmpxlabel',
                labels=[],
                show=False,
                grid=True,
                xticks=[],
                yticks=[],
                steps=5,
                save=False
            ):
    '''
    '''
    if not list(yaxis):
        yaxis = np.arange(len(counts))
    if not labels:
        labels = yaxis
    index = np.arange(len(yaxis))

    fig, ax = plt.subplots()
    fig.set_size_inches(figsize[0],figsize[1])
    plt.bar(index, counts, width)

    plt.title(title)
    if not xticks:
        print ('Making xticks')
        ticks = makeTicks(yMax=len(yaxis),steps=steps)
        xticks.append(ticks+width/2.)
        xticks.append(labels)
        print ('Done making xticks')

    if yticks:
        print ('Making yticks')
        # plt.yticks([1,2000],[0,100])
        plt.yticks(yticks[0],yticks[1])
        # ax.set_yticks(np.arange(0,100,10))
        print ('Done making yticks')

    plt.xticks(xticks[0]+width/2., xticks[1])
    plt.ylabel(ylabel)
    plt.xlabel(xlabel)
    # ax.set_xticks(range(0,len(counts)+2))

    fig.autofmt_xdate()
    # ax.set_xticklabels(ks)

    plt.axis([0, len(yaxis), 0, max(counts) + (max(counts)/100)])
    plt.grid(grid)
    location = ROOT_FOLDER + "/../muchBazar/src/image/" + k + "distribution.png"
    if save:
        plt.savefig(location)
        print ('Distribution written to: %s' % location)
    if show:
        plt.show()
开发者ID:mcmhav,项目名称:suchBazar,代码行数:60,代码来源:helpers.py

示例9: draw_robot_way_2d

def draw_robot_way_2d(data_1, data_2, label_names, plate_name):
    plt.plot(data_1, data_2)
    plt.xlabel(label_names[0])
    plt.ylabel(label_names[1])
    plt.title(plate_name)
    plt.grid(True)
    plt.show()
开发者ID:egorvlgavr,项目名称:Python,代码行数:7,代码来源:drawlines.py

示例10: plot_models

def plot_models(x, y, models, fname, mx=None, ymax=None, xmin=None):
    plt.clf()
    plt.scatter(x, y, s=10)
    plt.title("Web traffic over the last month")
    plt.xlabel("Time")
    plt.ylabel("Hits/hour")
    plt.xticks([w * 7 * 24 for w in range(10)], ["week %i" % w for w in range(10)])

    if models:
        if mx is None:
            mx = sp.linspace(0, x[-1], 1000)
        for model, style, color in zip(models, linestyles, colors):
            # print "Model:",model
            # print "Coeffs:",model.coeffs
            plt.plot(mx, model(mx), linestyle=style, linewidth=2, c=color)

        plt.legend(["d=%i" % m.order for m in models], loc="upper left")

    plt.autoscale(tight=True)
    plt.ylim(ymin=0)
    if ymax:
        plt.ylim(ymax=ymax)
    if xmin:
        plt.xlim(xmin=xmin)
    plt.grid(True, linestyle="-", color="0.75")
开发者ID:statistikR,项目名称:mlSystemPy,代码行数:25,代码来源:plottingUtil.py

示例11: createResponsePlot

def createResponsePlot(dataframe,plotdir):
    mag = dataframe['MAGPDE'].as_matrix()
    response = (dataframe['TFIRSTPUB'].as_matrix())/60.0
    response[response > 60] = 60 #anything over 60 minutes capped at 6 minutes
    imag5 = (mag >= 5.0).nonzero()[0]
    imag55 = (mag >= 5.5).nonzero()[0]
    fig = plt.figure(figsize=(8,6))
    n,bins,patches = plt.hist(response[imag5],color='g',bins=60,range=(0,60))
    plt.hold(True)
    plt.hist(response[imag55],color='b',bins=60,range=(0,60))
    plt.xlabel('Response Time (min)')
    plt.ylabel('Number of earthquakes')
    plt.xticks(np.arange(0,65,5))
    ymax = text.ceilToNearest(max(n),10)
    yinc = ymax/10
    plt.yticks(np.arange(0,ymax+yinc,yinc))
    plt.grid(True,which='both')
    plt.hold(True)
    x = [20,20]
    y = [0,ymax]
    plt.plot(x,y,'r',linewidth=2,zorder=10)
    s1 = 'Magnitude 5.0, Events = %i' % (len(imag5))
    s2 = 'Magnitude 5.5, Events = %i' % (len(imag55))
    plt.text(35,.85*ymax,s1,color='g')
    plt.text(35,.75*ymax,s2,color='b')
    plt.savefig(os.path.join(plotdir,'response.pdf'))
    plt.savefig(os.path.join(plotdir,'response.png'))
    plt.close()
    print 'Saving response.pdf'
开发者ID:mhearne-usgs,项目名称:neicq,代码行数:29,代码来源:neicq.py

示例12: show_trajectory

def show_trajectory(target, xc, yc):  # pragma: no cover
    plt.clf()
    plot_arrow(target.x, target.y, target.yaw)
    plt.plot(xc, yc, "-r")
    plt.axis("equal")
    plt.grid(True)
    plt.pause(0.1)
开发者ID:AtsushiSakai,项目名称:PythonRobotics,代码行数:7,代码来源:model_predictive_trajectory_generator.py

示例13: plot_data

def plot_data(l):
	fig, ax = plt.subplots()
	counts, bins, patches = ax.hist(l,30,facecolor='yellow', edgecolor='gray')

	# Set the ticks to be at the edges of the bins.
	#ax.set_xticks(bins)
	# Set the xaxis's tick labels to be formatted with 1 decimal place...
	#ax.xaxis.set_major_formatter(FormatStrFormatter('%0.1f'))

	
	# Label the raw counts and the percentages below the x-axis...
	bin_centers = 0.5 * np.diff(bins) + bins[:-1]
	for count, x in zip(counts, bin_centers):
	    # Label the raw counts
	    ax.annotate(str(int(count)), xy=(x, 0), xycoords=('data', 'axes fraction'),
	        xytext=(0, -40), textcoords='offset points', va='top', ha='center')

	    # Label the percentages
	    percent = '%0.0f%%' % (100 * float(count) / counts.sum())
	    ax.annotate(percent, xy=(x, 0), xycoords=('data', 'axes fraction'),
	        xytext=(0, -50), textcoords='offset points', va='top', ha='center')


	# Give ourselves some more room at the bottom of the plot
	plt.subplots_adjust(bottom=0.15)
	plt.grid(True)
	plt.xlabel("total reply")
	plt.ylabel("pages")
	plt.title("2014/10/21-2014/10/22  sina new pages")
	plt.show()
开发者ID:lxserenade,项目名称:crawler,代码行数:30,代码来源:data_process.py

示例14: visualize_singular_values

def visualize_singular_values(args):
    param_values = load_parameter_values(args.load_path)
    for d in range(args.layers):
        if args.rnn_type == 'lstm':
            ws = param_values["/recurrentstack/lstm_" + str(d) + ".W_state"]
            w_rec = ws[:, 3 * args.state_dim:]
        elif args.rnn_type == 'simple':
            w_rec = param_values["/recurrentstack/simplerecurrent_" + str(d) +
                                 ".W_state"]
        else:
            raise NotImplementedError
        U, s, V = np.linalg.svd(w_rec, full_matrices=True)
        plt.subplot(2, 1, 1)
        plt.plot(np.arange(s.shape[0]), s, label='Layer_' + str(d))
        plt.grid(True)
        plt.legend(loc='upper right')
        plt.title("Singular_values_of_recurrent_weights")
        plt.subplot(2, 1, 2)
        plt.plot(np.arange(s.shape[0]), np.log(s + 1E-15),
                 label='Layer_' + str(d))
        plt.grid(True)
        plt.title("Log_singular_values_of_recurrent_weights")
    plt.tight_layout()

    plt.savefig(args.save_path + "/visualize_singular_values.png")
    logger.info("Figure \"visualize_singular_values"
                ".png\" saved at directory: " + args.save_path)
开发者ID:anirudh9119,项目名称:RNN_Experiments,代码行数:27,代码来源:visualize_singular_values.py

示例15: exec_transmissions

    def exec_transmissions():
        IP,IP_AP,files=parser_reduce()
        plt.figure("GRAPHE_D'EVOLUTION_DES_TRANSMISSIONS")
        ENS_TEMPS_, TRANSMISSION_ = transmissions(files)
        plt.plot(ENS_TEMPS_, TRANSMISSION_,"r.", label="Transmissions: ")

        lot = map(inet_aton, IP)
        lot.sort()
        iplist1 = map(inet_ntoa, lot)

        for i in iplist1: #ici j'affiche les annotations et vérifie si j'ai des @ip de longueur 9 ou 8 pour connaitre la taille de la fenetre du graphe
                if len(i)==9:
                    maxim_=i[-2:] #Sera utilisé pour la taille de la fenetre du graphe
                    plt.annotate('   Machine: '+ i ,horizontalalignment='left', xy=(1, float(i[-2:])), xytext=(1, float(i[-2:])-0.4),arrowprops=dict(facecolor='black', shrink=0.05),)
                else:
                    maxim_=i[-1:] #Sera utilisé pour la taille de la fenetre du graphe
                    plt.annotate('   Machine: '+ i ,horizontalalignment='left', xy=(1, float(i[7])), xytext=(1, float(i[7])-0.4),arrowprops=dict(facecolor='black', shrink=0.05),)
        for i in IP_AP: #ACCESS POINT ( cas spécial )
            if i[-2:]:
                plt.annotate('   access point: '+ i , xy=(1, i[7]), xytext=(1, float(i[7])-0.4),arrowprops=dict(facecolor='black', shrink=0.05),)

        plt.ylim(0, (float(maxim_))+1) #C'est à ça que sert le tri
        plt.xlim(1, 1.1)
        plt.legend(loc='best',prop={'size':10})
        plt.xlabel('Temps (s)')
        plt.ylabel('IP machines transmettrices')
        plt.grid(True)
        plt.title("GRAPHE_D'EVOLUTION_DES_TRANSMISSIONS")
        plt.legend(loc='best')
        plt.show()
开发者ID:Belkacem200,项目名称:PROGRES-PROJET2_MODULE1,代码行数:30,代码来源:projet+Progres_2_.py


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