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


Python pylab.clf方法代码示例

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


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

示例1: plot_evaluation_episode_reward

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot_evaluation_episode_reward():
	pylab.clf()
	sns.set_context("poster")
	pylab.plot(0, 0)
	episodes = [0]
	average_scores = [0]
	median_scores = [0]
	for n in xrange(len(csv_evaluation)):
		params = csv_evaluation[n]
		episodes.append(params[0])
		average_scores.append(params[1])
		median_scores.append(params[2])
	pylab.plot(episodes, average_scores, sns.xkcd_rgb["windows blue"], lw=2)
	pylab.xlabel("episodes")
	pylab.ylabel("average score")
	pylab.savefig("%s/evaluation_episode_average_reward.png" % args.plot_dir)

	pylab.clf()
	pylab.plot(0, 0)
	pylab.plot(episodes, median_scores, sns.xkcd_rgb["windows blue"], lw=2)
	pylab.xlabel("episodes")
	pylab.ylabel("median score")
	pylab.savefig("%s/evaluation_episode_median_reward.png" % args.plot_dir) 
开发者ID:musyoku,项目名称:double-dqn,代码行数:25,代码来源:experiment.py

示例2: plotdata

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plotdata(obsmode,spectrum,val,odict,sdict,
             instr,fieldname,outdir,outname):
    isetting=P.isinteractive()
    P.ioff()

    P.clf()
    P.plot(obsmode,val,'.')
    P.ylabel('(pysyn-syn)/syn')
    P.xlabel('obsmode')
    P.title("%s: %s"%(instr,fieldname))
    P.savefig(os.path.join(outdir,outname+'_obsmode.ps'))

    P.clf()
    P.plot(spectrum,val,'.')
    P.ylabel('(pysyn-syn)/syn')
    P.xlabel('spectrum')
    P.title("%s: %s"%(instr,fieldname))
    P.savefig(os.path.join(outdir,outname+'_spectrum.ps'))

    matplotlib.interactive(isetting) 
开发者ID:spacetelescope,项目名称:pysynphot,代码行数:22,代码来源:doscalars.py

示例3: summary

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def summary(self, Nbest=5, lw=2, plot=True, method="sumsquare_error"):
        """Plots the distribution of the data and Nbest distribution

        """
        if plot:
            pylab.clf()
            self.hist()
            self.plot_pdf(Nbest=Nbest, lw=lw, method=method)
            pylab.grid(True)

        Nbest = min(Nbest, len(self.distributions))
        try:
            names = self.df_errors.sort_values(
                by=method).index[0:Nbest]
        except:
            names = self.df_errors.sort(method).index[0:Nbest]
        return self.df_errors.loc[names] 
开发者ID:cokelaer,项目名称:fitter,代码行数:19,代码来源:fitter.py

示例4: plot_functional_map

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot_functional_map(C, newfig=True):
    vmax = max(np.abs(C.max()), np.abs(C.min()))
    vmin = -vmax
    C = ((C - vmin) / (vmax - vmin)) * 2 - 1
    if newfig:
        pl.figure(figsize=(5,5))
    else:
        pl.clf()
    ax = pl.gca()
    pl.pcolor(C[::-1], edgecolor=(0.9, 0.9, 0.9, 1), lw=0.5,
              vmin=-1, vmax=1, cmap=nice_mpl_color_map())
    # colorbar
    tick_locs   = [-1., 0.0, 1.0]
    tick_labels = ['min', 0, 'max']
    bar = pl.colorbar()
    bar.locator = matplotlib.ticker.FixedLocator(tick_locs)
    bar.formatter = matplotlib.ticker.FixedFormatter(tick_labels)
    bar.update_ticks()
    ax.set_aspect(1)
    pl.xticks([])
    pl.yticks([])
    if newfig:
        pl.show() 
开发者ID:tneumann,项目名称:cmm,代码行数:25,代码来源:functional_map.py

示例5: scattered_visual_brightness

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def scattered_visual_brightness ():
    '''Plot the perceptual brightness of Rayleigh scattered light.'''
    # get 'spectra' for y matching functions and multiply by 1/wl^4
    spectrum_y = ciexyz.empty_spectrum()
    (num_wl, num_cols) = spectrum_y.shape
    for i in range (0, num_wl):
        wl_nm = spectrum_y [i][0]
        rayleigh = math.pow (550.0 / wl_nm, 4)
        xyz = ciexyz.xyz_from_wavelength (wl_nm)
        spectrum_y [i][1] = xyz [1] * rayleigh
    pylab.clf ()
    pylab.title ('Perceptual Brightness of Rayleigh Scattered Light')
    pylab.xlabel ('Wavelength (nm)')
    pylab.ylabel ('CIE $Y$ / $\lambda^4$')
    spectrum_subplot (spectrum_y)
    tighten_x_axis (spectrum_y [:,0])
    # done
    filename = 'Visual_scattering'
    print ('Saving plot %s' % str (filename))
    pylab.savefig (filename) 
开发者ID:markkness,项目名称:ColorPy,代码行数:22,代码来源:plots.py

示例6: plotFields

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plotFields(layer,fieldShape=None,channel=None,figOffset=1,cmap=None,padding=0.01):
	# Receptive Fields Summary
	try:
		W = layer.W
	except:
		W = layer
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)	
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))

	fig = mpl.figure(figOffset); mpl.clf()
	
	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,np.shape(fields)[0]):
		im = grid[i].imshow(fields[i],cmap=cmap); 

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)
	
	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	# 
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figOffset+1); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:41,代码来源:TensorFlowInterface.py

示例7: plotOutput

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plotOutput(layer,feed_dict,fieldShape=None,channel=None,figOffset=1,cmap=None):
	# Output summary
	try:
		W = layer.output
	except:
		W = layer
	wp = W.eval(feed_dict=feed_dict);
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		temp = np.zeros(np.product(fieldShape)); temp[0:np.shape(wp.ravel())[0]] = wp.ravel()
		fields = np.reshape(temp,[1]+fieldShape)
	else:			# Convolutional layer already has shape
		wp = np.rollaxis(wp,3,0)
		features, channels, iy,ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))
	fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	tiled = []
	for i in range(0,perColumn*perRow,perColumn):
		tiled.append(np.hstack(fields2[i:i+perColumn]))

	tiled = np.vstack(tiled)
	if figOffset is not None:
		mpl.figure(figOffset); mpl.clf(); 

	mpl.imshow(tiled,cmap=cmap); mpl.title('%s Output' % layer.name); mpl.colorbar(); 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:32,代码来源:TensorFlowInterface.py

示例8: plotFields

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plotFields(layer,fieldShape=None,channel=None,maxFields=25,figName='ReceptiveFields',cmap=None,padding=0.01):
	# Receptive Fields Summary
	W = layer.W
	wp = W.eval().transpose();
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		fields = np.reshape(wp,list(wp.shape[0:-1])+fieldShape)
	else:			# Convolutional layer already has shape
		features, channels, iy, ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	fieldsN = min(fields.shape[0],maxFields)
	perRow = int(math.floor(math.sqrt(fieldsN)))
	perColumn = int(math.ceil(fieldsN/float(perRow)))

	fig = mpl.figure(figName); mpl.clf()

	# Using image grid
	from mpl_toolkits.axes_grid1 import ImageGrid
	grid = ImageGrid(fig,111,nrows_ncols=(perRow,perColumn),axes_pad=padding,cbar_mode='single')
	for i in range(0,fieldsN):
		im = grid[i].imshow(fields[i],cmap=cmap);

	grid.cbar_axes[0].colorbar(im)
	mpl.title('%s Receptive Fields' % layer.name)

	# old way
	# fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	# tiled = []
	# for i in range(0,perColumn*perRow,perColumn):
	# 	tiled.append(np.hstack(fields2[i:i+perColumn]))
	#
	# tiled = np.vstack(tiled)
	# mpl.figure(figOffset); mpl.clf(); mpl.imshow(tiled,cmap=cmap); mpl.title('%s Receptive Fields' % layer.name); mpl.colorbar();
	mpl.figure(figName+' Total'); mpl.clf(); mpl.imshow(np.sum(np.abs(fields),0),cmap=cmap); mpl.title('%s Total Absolute Input Dependency' % layer.name); mpl.colorbar() 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:39,代码来源:TensorFlowInterface.py

示例9: plotOutput

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plotOutput(layer,feed_dict,fieldShape=None,channel=None,figOffset=1,cmap=None):
	# Output summary
	W = layer.output
	wp = W.eval(feed_dict=feed_dict);
	if len(np.shape(wp)) < 4:		# Fully connected layer, has no shape
		temp = np.zeros(np.product(fieldShape)); temp[0:np.shape(wp.ravel())[0]] = wp.ravel()
		fields = np.reshape(temp,[1]+fieldShape)
	else:			# Convolutional layer already has shape
		wp = np.rollaxis(wp,3,0)
		features, channels, iy,ix = np.shape(wp)
		if channel is not None:
			fields = wp[:,channel,:,:]
		else:
			fields = np.reshape(wp,[features*channels,iy,ix])

	perRow = int(math.floor(math.sqrt(fields.shape[0])))
	perColumn = int(math.ceil(fields.shape[0]/float(perRow)))
	fields2 = np.vstack([fields,np.zeros([perRow*perColumn-fields.shape[0]] + list(fields.shape[1:]))])
	tiled = []
	for i in range(0,perColumn*perRow,perColumn):
		tiled.append(np.hstack(fields2[i:i+perColumn]))

	tiled = np.vstack(tiled)
	if figOffset is not None:
		mpl.figure(figOffset); mpl.clf();

	mpl.imshow(tiled,cmap=cmap); mpl.title('%s Output' % layer.name); mpl.colorbar(); 
开发者ID:robb-brown,项目名称:IntroToDeepLearning,代码行数:29,代码来源:TensorFlowInterface.py

示例10: save_plots

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def save_plots(self, folder):

        import pylab as pl

        pl.gcf().set_size_inches(15, 15)

        pl.clf()
        self.homography.plot_original()
        pl.savefig(join(folder, 'homography-original.jpg'))

        pl.clf()
        self.homography.plot_rectified()
        pl.savefig(join(folder, 'homography-rectified.jpg'))

        pl.clf()
        self.driving_layers.plot(overlay_alpha=0.7)
        pl.savefig(join(folder, 'segnet-driving.jpg'))

        pl.clf()
        self.facade_layers.plot(overlay_alpha=0.7)
        pl.savefig(join(folder, 'segnet-i12-facade.jpg'))

        pl.clf()
        self.plot_grids()
        pl.savefig(join(folder, 'grid.jpg'))

        pl.clf()
        self.plot_regions()
        pl.savefig(join(folder, 'regions.jpg'))

        pl.clf()
        pl.gcf().set_size_inches(6, 4)
        self.plot_facade_cuts()
        pl.savefig(join(folder, 'facade-cuts.jpg'), dpi=300)
        pl.savefig(join(folder, 'facade-cuts.svg'))

        imsave(join(folder, 'walls.png'), self.wall_colors) 
开发者ID:jfemiani,项目名称:facade-segmentation,代码行数:39,代码来源:megafacade.py

示例11: plot_episode_reward

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot_episode_reward():
	pylab.clf()
	sns.set_context("poster")
	pylab.plot(0, 0)
	episodes = [0]
	scores = [0]
	for n in xrange(len(csv_episode)):
		params = csv_episode[n]
		episodes.append(params[0])
		scores.append(params[1])
	pylab.plot(episodes, scores, sns.xkcd_rgb["windows blue"], lw=2)
	pylab.xlabel("episodes")
	pylab.ylabel("score")
	pylab.savefig("%s/episode_reward.png" % args.plot_dir) 
开发者ID:musyoku,项目名称:double-dqn,代码行数:16,代码来源:experiment.py

示例12: plot_training_episode_highscore

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot_training_episode_highscore():
	pylab.clf()
	sns.set_context("poster")
	pylab.plot(0, 0)
	episodes = [0]
	highscore = [0]
	for n in xrange(len(csv_training_highscore)):
		params = csv_training_highscore[n]
		episodes.append(params[0])
		highscore.append(params[1])
	pylab.plot(episodes, highscore, sns.xkcd_rgb["windows blue"], lw=2)
	pylab.xlabel("episodes")
	pylab.ylabel("highscore")
	pylab.savefig("%s/training_episode_highscore.png" % args.plot_dir) 
开发者ID:musyoku,项目名称:double-dqn,代码行数:16,代码来源:experiment.py

示例13: plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot(self, filename=None, vmin=None, vmax=None, cmap='jet_r'):
        import pylab
        pylab.clf()
        pylab.imshow(-np.log10(self.results[self._start_y:,:]), 
            origin="lower",
            aspect="auto", cmap=cmap, vmin=vmin, vmax=vmax)
        pylab.colorbar()

        # Fix xticks
        XMAX = float(self.results.shape[1])  # The max integer on xaxis
        xpos = list(range(0, int(XMAX), int(XMAX/5)))
        xx = [int(this*100)/100 for this in np.array(xpos) / XMAX * self.duration]
        pylab.xticks(xpos, xx, fontsize=16)

        # Fix yticks
        YMAX = float(self.results.shape[0])  # The max integer on xaxis
        ypos = list(range(0, int(YMAX), int(YMAX/5)))
        yy = [int(this) for this in np.array(ypos) / YMAX * self.sampling]
        pylab.yticks(ypos, yy, fontsize=16)

        #pylab.yticks([1000,2000,3000,4000], [5500,11000,16500,22000], fontsize=16)
        #pylab.title("%s echoes" %  filename.replace(".png", ""), fontsize=25)
        pylab.xlabel("Time (seconds)", fontsize=25)
        pylab.ylabel("Frequence (Hz)", fontsize=25)
        pylab.tight_layout()
        if filename:
            pylab.savefig(filename) 
开发者ID:cokelaer,项目名称:spectrum,代码行数:29,代码来源:spectrogram.py

示例14: calc_prominence

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def calc_prominence(params, labels, func=np.max, use_peaks = True):
    labelled = []
    norm = params.astype(float)
    for (start, end, word) in labels:
   
        if end -start == 0:
            continue
        #print start, end, word
        if use_peaks:
            peaks = []
            #pylab.clf()
            #pylab.plot(params[start:end])

            (peaks, indices)=get_peaks(params[start:end])

            if len(peaks) >0:
                labelled.append(np.max(peaks))
               
                #labelled.append(norm[start-5+peaks[0]])
                # labelled.append([word,func(params[start:end])])
                
            else:
                labelled.append(0.0)
        else:
            #labelled.append([word, func(params[start-10:end])])
            labelled.append(func(params[start:end]))
        
        #raw_input()
	
    return labelled 
开发者ID:CSTR-Edinburgh,项目名称:Ossian,代码行数:32,代码来源:cwt_utils.py

示例15: plot_mpc_preview

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import clf [as 别名]
def plot_mpc_preview(self):
        import pylab
        T = self.mpc_timestep
        h = stance.com.z
        g = -sim.gravity[2]
        trange = [sim.time + k * T for k in range(len(self.x_mpc.X))]
        pylab.ion()
        pylab.clf()
        pylab.subplot(211)
        pylab.plot(trange, [v[0] for v in self.x_mpc.X])
        pylab.plot(trange, [v[0] - v[2] * h / g for v in self.x_mpc.X])
        pylab.subplot(212)
        pylab.plot(trange, [v[0] for v in self.y_mpc.X])
        pylab.plot(trange, [v[0] - v[2] * h / g for v in self.y_mpc.X]) 
开发者ID:stephane-caron,项目名称:pymanoid,代码行数:16,代码来源:horizontal_walking.py


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