本文整理汇总了Python中pylab.cla函数的典型用法代码示例。如果您正苦于以下问题:Python cla函数的具体用法?Python cla怎么用?Python cla使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cla函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_fft_brams
def plot_fft_brams():
import pylab
run = True
# turn on live updating
pylab.ion()
# plot the power in log scale
pylab.yscale('log')
# get an initial power spectrum and plot the power lines as rectangles
fftscope_power = get_fft_brams_power()
fftscope_power_line=pylab.bar(range(0,numchannels),fftscope_power)
pylab.ylim(1,1000000)
# plot until an interrupt is received
# for i in range(1,10):
while(run):
try:
# read in a new spectrum
fftscope_power = get_fft_brams_power()
# update the rectangles based on the new power spectrum
for j in range(0,numchannels):
fftscope_power_line[j].set_height(fftscope_power[j])
#update the plot
pylab.draw()
except KeyboardInterrupt:
run = False
# after stopping the liveupdate leave the plot up until the user is done with it
raw_input('Press enter to quit: ')
pylab.cla()
开发者ID:Vereese,项目名称:tutorials_devel,代码行数:34,代码来源:gpu_spec_init.py
示例2: plot
def plot(self, frame, position, offset):
global plot
if plot:
fname = "/tmp/autoguider.fits"
if os.path.exists(fname):
os.remove(fname)
frame.save(fname)
img = fits.getdata(fname)
hdr = fits.getheader(fname)
py.figure(1)
py.cla()
py.imshow(img, origin="lower", interpolation="nearest", vmax=np.mean(img) * 1.1, cmap=py.cm.gray)
py.plot(position["XWIN_IMAGE"], position["YWIN_IMAGE"], "b+")
py.plot(position["XWIN_IMAGE"] + offset["X"], position["YWIN_IMAGE"] + offset["Y"], "rx")
py.plot(position["XWIN_IMAGE"] - hdr["offsetY"] + 1, position["YWIN_IMAGE"] - hdr["offsetX"], "r.")
err = np.sqrt(((-hdr["offsetY"] + 1 - offset["X"]) ** 2) + ((-hdr["offsetX"] - offset["Y"]) ** 2))
py.text(
-3,
-3,
"Offset: (%.2f/%.2f) px, Calculated: (%.2f/%.2f) px, Error: %3.2f"
% (-hdr["offsetY"] + 1, -hdr["offsetX"], offset["X"], offset["Y"], err),
)
py.savefig(os.path.join(SYSTEM_CONFIG_DIRECTORY, "autoguider_%05i.png") % self.index)
py.show()
self.index += 1
开发者ID:tribeiro,项目名称:chimera-autoguider,代码行数:28,代码来源:autoguider.py
示例3: PlotGrids
def PlotGrids(gs, grids=None, drawnow=True):
"""
Plot the grids, each on a separate subplot if there are more than one, to be sure of the
row and column coordinates inferred for each numbered electrode.
NB: requires installation of the matplotlib python package (including the pylab module)
for plotting.
"""###
import pylab
each = EachGrid(gs, grids=grids)
ngrids = len(each)
for rows in range(int(ngrids**0.5), 0, -1):
if ngrids % rows == 0: cols = ngrids / rows; break
else: rows = int(ngrids**0.5); cols = int(math.ceil(ngrids/float(rows)))
if ngrids != 1: pylab.clf()
for i,(gridname,g) in enumerate(each):
if ngrids != 1: pylab.subplot(rows, cols, i+1)
pylab.cla()
xcoords,ycoords = [],[]
for trode in g:
row,col,val = trode.localRowIndex,trode.localColumnIndex,trode.localNumber
xcoords.append(col); ycoords.append(row)
pylab.text(col, row, str(val), horizontalalignment='center', verticalalignment='center')
pylab.xlim(min(xcoords)-1, max(xcoords)+1)
pylab.ylim(max(ycoords)+1, min(ycoords)-1)
pylab.grid('on')
pylab.title(gridname)
if drawnow:
pylab.draw()
pylab.show()
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:31,代码来源:ElectrodeGrids.py
示例4: do_plots_c
def do_plots_c(Ud, Unew):
""" plot Ud,new and Ud with zoom on the bug """
pylab.clf()
pylab.cla()
f = pylab.figure()
f.text(.5, .95, r"$U_{\rm d}$ (left) and $U_{\rm d, new}$ (right) ",
horizontalalignment='center')
pylab.subplot(221)
pylab.imshow(Ud[0])
pylab.ylabel("# of cells", size=8)
pylab.subplot(223)
pylab.imshow(Ud[1])
pylab.xlim(1, 32)
pylab.xlabel("# of cells", size=8)
pylab.ylabel("# of cells", size=8)
pylab.subplot(222)
pylab.imshow(Unew[0])
pylab.ylabel("# of cells", size=8)
pylab.subplot(224)
pylab.imshow(Unew[1])
pylab.xlim(1, 32)
pylab.xlabel("# of cells", size=8)
pylab.ylabel("# of cells", size=8)
pylab.savefig("plots/item_c_Udnew.png")
开发者ID:NicovincX2,项目名称:Python-3.5,代码行数:30,代码来源:ellPDE_part_c.py
示例5: scan
def scan():
pylab.ion()
pylab.figure(1)
with Communicate('', None, debug=True) as serial:
serial.timeout = 0.0001
camera = Camera()
camera.setupmeasure()
controller = Controller(serial)
controller.setupscan()
out = []
for x,y in controller.scan():
camera.update()
camera.interact()
z = camera.measure()
out.append([x,y,z])
if camera.status == 'quit':
break
camera.show()
if len(out) > 0:
pylab.cla()
tmp = zip(*out)
sc = pylab.scatter(tmp[0],tmp[1],s=tmp[2], c=tmp[2], vmin=0, vmax=400)
print '{: 8.3f} {: 8.3f} {: 8.3f}'.format(x,y,z)
pylab.ioff()
pylab.show()
开发者ID:bkurtz,项目名称:PyGRBL,代码行数:33,代码来源:orient.py
示例6: plotDC
def plotDC(vp,block,trial):
''' plot gaze during drift correction'''
from Preprocess import readEyelink
plt.interactive(False)
# vp=1
# from readETData import readEyelink
# for b in range(4,23):
# print 'block ', b
# data=readEyelink(vp,b)
# for i in range(0,len(data)):
b=block;i=trial
data=readEyelink(vp,b)
d=data[i]
gg=d.getGaze(phase=3)
plt.plot(gg[:,0],gg[:,1],'g--')
plt.plot(gg[:,0],gg[:,2],'r--')
plt.plot(gg[:,0],gg[:,4],'b--')
plt.plot(gg[:,0],gg[:,5],'k--')
d.extractBasicEvents()
d.driftCorrection(jump=manualDC(vp,b,i))
gg=d.getGaze(phase=3)
plt.plot(gg[:,0],gg[:,1],'g')
plt.plot(gg[:,0],gg[:,2],'r')
plt.plot(gg[:,0],gg[:,4],'b')
plt.plot(gg[:,0],gg[:,5],'k')
plt.plot([gg[0,0],gg[-1,0]],[0,0],'k')
plt.plot(d.dcfix,[-0.45,-0.45],'k',lw=2)
plt.grid()
plt.ylim([-0.5,0.5])
plt.legend(['left x','left y','right x','right y'])
plt.savefig(PATH+'dc'+os.path.sep+'vp%03db%02dtr%02d'%(vp,b,i))
plt.cla()
开发者ID:simkovic,项目名称:GoalDirectedMotionPsychoexperiments,代码行数:32,代码来源:ETData.py
示例7: draw_hist_cdf
def draw_hist_cdf(data,fig=None,nbins=None,subpl=None,nohist=False,**figargs):
'''input data is a list of dicts with keys: data,histcolor,plotline
'''
bins = None
if fig: pylab.figure(fig,**figargs)
if subpl: pylab.subplot(subpl)
results = []
for d in data:
if bins is not None:
n,bins,patches=pylab.hist(d['data'],bins=bins,normed=1,fc=histcolors[d['plotline'][0]])
elif nbins is not None:
n,bins,patches=pylab.hist(d['data'],bins=nbins,normed=1,fc=histcolors[d['plotline'][0]])
else:
n,bins,patches=pylab.hist(d['data'],normed=1,fc=histcolors[d['plotline'][0]])
results.append(n)
if nohist:
pylab.cla()
else:
pylab.twinx()
for i,d in enumerate(data):
y = pylab.plot(bins,numpy.cumsum(results[i])/sum(results[i]), d['plotline'], linewidth=2)
开发者ID:brantp,项目名称:py_util,代码行数:26,代码来源:iplot.py
示例8: plotPhaseSpace
def plotPhaseSpace(b, aTheta, aOmega, t, power, k):
pylab.clf()
pylab.cla()
label = str(b)
pylab.subplot(221)
pylab.plot(aTheta, aOmega, color="m", lw=2)
pylab.xlabel(r"$\theta$ (radians) ", fontsize=10)
pylab.ylabel('$\omega$ (radians/seconds)', fontsize=10)
pylab.grid(True)
pylab.subplot(222)
pylab.plot(t, aTheta, color="g", lw=2)
pylab.ylabel(r"$\theta$ (radians)", fontsize=10)
pylab.xlabel('t (seconds)', fontsize=10)
pylab.grid(True)
pylab.subplot(223)
pyplot.grid(True)
pyplot.plot(k, power, color="c", lw=2)
pyplot.ylabel("|F(k)$|^{2}$", fontsize=10)
pyplot.xlabel(r"$\nu_k$ ($s^{-1}$)", fontsize=10)
pylab.subplot(224)
pyplot.yscale('log')
pyplot.plot(2.0 * numpy.pi * k, power, color="b", lw=1)
pylab.xlim(0, 6)
pyplot.grid(True)
pyplot.xlabel(r"$\nu_k$ ($s^{-1}$)", fontsize=10)
pyplot.ylabel("log |F(k)$|^{2}$", fontsize=10)
pylab.savefig("plots/b-%s_phase_space.png" % (label))
return 0
开发者ID:NicovincX2,项目名称:Python-3.5,代码行数:35,代码来源:tsa_plotter.py
示例9: main
def main():
filenames = glob.glob("*.dat")
filenames = sort(filenames) #yeah, python is easy
N = len(filenames)
picture = zeros((N,N))
pylab.cla()
stepcount = 1
for i in filenames:
file = open(i)
data = array(file.read().strip().split(" "))
#put the data into the 2D picture array
for j in range(N):
# print data[j]==str(1), " dataj ", type(data[j])
if data[j] == str(1):
picture[0:stepcount,j] = data[j]
pylab.imshow(picture)
fname = re.sub("dat", "png", i)
pylab.savefig(fname)
stepcount += 1
print i
make_pngs_into_an_avi(.5)
os.system("rm *dat")
os.system("rm *png")
return
开发者ID:rcompton,项目名称:ryancompton.net,代码行数:33,代码来源:make_fft_movie.py
示例10: plot_fft_brams
def plot_fft_brams(new_pasp):
run = True
pylab.ion()
pylab.cla()
pylab.yscale("log")
# read in initial data from the fft brams
fftscope_power = new_pasp.get_fft_brams_power()
# set up bars for each pasp channel
fftscope_power_line = pylab.bar(range(0, new_pasp.numchannels), fftscope_power)
pylab.ylim(1, 1000000)
# plot forever
# for i in range(1,10):
while run:
try:
fftscope_power = new_pasp.get_fft_brams_power()
# update the rectangles
for j in range(0, new_pasp.numchannels):
fftscope_power_line[j].set_height(fftscope_power[j])
pylab.draw()
except KeyboardInterrupt:
run = False
# after receiving an interrupt wait before closing the plot
raw_input("Press enter to quit: ")
pylab.cla()
开发者ID:casper-berkeley,项目名称:pasp,代码行数:32,代码来源:pasp_plot.py
示例11: plot_adc_brams
def plot_adc_brams(new_pasp):
run = True
pylab.ion()
# pylab.yscale('log')
# read in the adc data
adcscope_pol1, adcscope_pol2 = new_pasp.get_adc_brams(100)
print adcscope_pol1
pylab.cla()
adcscope_power_line, = pylab.plot(adcscope_pol1)
# while(run):
"""
for i in range(1,10):
try:
fftscope_power = get_fft_brams_power()
fftscope_power_line.set_ydata(fftscope_power)
pylab.draw()
except KeyboardInterrupt:
run = False
"""
raw_input("Press enter to quit: ")
pylab.cla()
开发者ID:casper-berkeley,项目名称:pasp,代码行数:28,代码来源:pasp_plot.py
示例12: twoDimOrderPlot
def twoDimOrderPlot(outpath, base_name, title, obj_name, base_filename, order_num, data, x):
pl.figure('2d order image', facecolor='white', figsize=(8, 5))
pl.cla()
pl.title(title + ', ' + base_name + ", order " + str(order_num), fontsize=14)
pl.xlabel('wavelength($\AA$)', fontsize=12)
pl.ylabel('row (pixel)', fontsize=12)
#pl.imshow(img, aspect='auto')
#pl.imshow(data, vmin=0, vmax=1024, aspect='auto')
pl.imshow(exposure.equalize_hist(data), origin='lower',
extent=[x[0], x[-1], 0, data.shape[0]], aspect='auto')
# from matplotlib import colors
# norm = colors.LogNorm(data.mean() + 0.5 * data.std(), data.max(), clip='True')
# pl.imshow(data, norm=norm, origin='lower',
# extent=[x[0], x[-1], 0, data.shape[0]], aspect='auto')
pl.colorbar()
pl.set_cmap('jet')
# pl.set_cmap('Blues_r')
fn = constructFileName(outpath, base_name, order_num, base_filename)
pl.savefig(fn)
log_fn(fn)
pl.close()
# np.save(fn[:fn.rfind('.')], data)
return
开发者ID:2ichard,项目名称:nirspec_drp,代码行数:26,代码来源:products.py
示例13: draw
def draw():
pl.cla()
nodeSize=[1000*net.in_degree(n) for n in nx.nodes(net)]
nx.draw(net, pos = positions, node_color = [net.node[i]['id'] for i in net.nodes_iter()], with_labels = True, edge_color = 'c', cmap = pl.cm.RdBu, vmin = 0, vmax = 1,node_size=nodeSize, alpha=0.75)
pl.axis('image')
pl.title('t = ' + str(time))
plt.show()
开发者ID:CA-Lab,项目名称:moral-exchange,代码行数:7,代码来源:net-r-c-in_fitness.py
示例14: graph
def graph(toKeep):
"""Used to display the graphs. Text will be shown before hand as
the graphs take time to generate"""
global firstTime
#Display some text stating that graphs are being generated
if toKeep == TwelveHours:
displayText('Creating', 35, 1,(200,200,1),True)
displayText('12 Hour Graph', 32, 2,(150,150,255), False)
elif toKeep == TwentyFourHours:
displayText('Creating', 35, 1,(200,200,1), True)
displayText('24 Hour Graph', 32, 2,(150,150,255), False)
elif toKeep == OneWeek:
displayText('Creating', 35, 1,(200,200,1), True)
displayText('One Week Graph', 28, 2,(150,150,255), False)
pygame.display.flip()
#Get temperature and time data from data file
temp = genfromtxt('temperature_logging', dtype=None, usecols=(0), skip_header = lines - toKeep)
timecaptured = genfromtxt('temperature_logging', dtype=None, usecols=(1), skip_header = lines - toKeep)
#Site the size of the font for the axis
for label in ax.get_xticklabels():
label.set_fontsize(8)
for label in ax.get_yticklabels():
label.set_fontsize(8)
#Create xaxis labels and only show every 12th or 96th
xlabels = range(toKeep)
if toKeep == OneWeek:
pylab.xticks(xlabels[::96], [v[:5:] for v in timecaptured[::96]])
else:
pylab.xticks(xlabels[::12], [v[11:16] for v in timecaptured[::12]])
#Plot the graph
pylab.plot(temp,linewidth=2, antialiased=True)
#Change some colours
ax.patch.set_facecolor('#FFFFCC')
ax.patch.set_alpha(0.5)
#Rotate the text in the xaxis
fig.autofmt_xdate(rotation=90)
#Set the yaxsis limits
pylab.ylim(0,40)
#Save the graph as an image and the re-open it, rotate it and then display to TFT.
pylab.savefig('gp.png', facecolor=fig.get_facecolor(),bbox_inches='tight', dpi=80,pad_inches=0.03)
pil_im = Image.open('gp.png')
pil_out = pil_im.rotate(-90)
pil_out.save("gp.png")
img = pygame.image.load('gp.png')
screen.blit(img,(0,0))
pygame.display.flip()
#Clear graph data in preparation for next plot
pylab.cla()
#Reset the firstTime Variable
firstTime = 0
开发者ID:Darth-Neo,项目名称:pyrpi,代码行数:60,代码来源:temp_example.py
示例15: draw
def draw(figure):
global resources, time, theWorld, cmap, files
PL.cla()
cmap.set_under()
PL.pcolormesh(theWorld.foraging_resources, cmap = cmap, vmin=0,
vmax=W.max_resource)
PL.axis('scaled')
PL.hold(True)
xyp = zip(*[theWorld.hh_locations[hh] for hh in theWorld.households])
xy = [list(t) for t in xyp]
if len(xy)>0:
x = [i+0.5 for i in xy[0]]
y = [i+0.5 for i in xy[1]]
lineage = [hh.lineage for hh in (theWorld.households)]
hh_size = [20*hh.size() for hh in (theWorld.households)]
PL.scatter(y, x, c = lineage, s=hh_size, vmin=0, vmax=W.starting_agents, cmap = plt.get_cmap('hsv'))
message = r't = {0} Pop.: {1} HHs: {2} max HHs: {3}'
PL.title(message.format(time, theWorld.population, len(theWorld.households), max(lineage)))
PL.hold(False)
figure.tight_layout()
if MOVIES:
fname = dirName+('\\_temp%05d.png'%time)
figure.savefig(fname)
files.append(fname)
drawPlots()
开发者ID:strangeintp,项目名称:food-network-inequality,代码行数:27,代码来源:foraging_simGUI.py
示例16: plotDistHist
def plotDistHist(filtered, options):
shifts = []
oldShifts = []
for chrom in filtered:
count = 0
for p in filtered[chrom]:
p.getCC()
p.getOldShift()
shifts.append(p.shift)
oldShifts.append(p.old_shift)
if options.savefig >= 0:
if options.rpm == options.savefig and count < 20 and np.random.rand() >= 0.5:
dirname = "%s/%d"%(getOutput(options),p.shift/10)
if not os.path.exists(dirname):
os.system("mkdir -p " + dirname)
p.plot(dirname)
count += 1
import pylab as pl
pl.figure()
pl.subplot(211)
pl.hist(shifts, bins=100, range=(0,200))
pl.subplot(212)
pl.hist(oldShifts, bins=100, range=(0,200))
pl.savefig(getOutput(options)+"_shifts.png",dpi=600)
pl.cla()
pl.clf()
pl.close()
开发者ID:hjanime,项目名称:CSI,代码行数:29,代码来源:test_pair_cc.py
示例17: weightedAffineInvCompWarpCost
def weightedAffineInvCompWarpCost(targetIMG, templateIMG, templateWeight, curParameters, displayStuff, targetIMGMask = None):
#function [ImageWarpedToTemplate, TX, TY, ErrorIMG, CostValue] = lk_weighted_run_affine_inv_comp_warpcost(targetIMG, templateIMG, TemplateW, CurParameters, displayStuff)
# [ImageWarpedToTemplate, TX, TY] = lk_warp_image_affine(targetIMG, size(templateIMG), CurParameters);
targetIMGToTemplate, TX, TY = warpImageAffine(targetIMG, templateIMG.shape, curParameters)
if displayStuff == True:
pylab.subplot(4, 3, 5); CCSegUtils.showIMG(targetIMGToTemplate); pylab.title('template coordinates warped to image');
pylab.subplot2grid((4, 3), (1, 2), rowspan = 2, colspan = 1); pylab.cla(); CCSegUtils.showIMG(targetIMG);
pylab.plot(TX[:, 0], TY[:, 0], 'b-')
pylab.plot(TX[0, :], TY[0, :], 'b-')
pylab.plot(TX[:, -1], TY[:, -1], 'b-')
pylab.plot(TX[-1, :], TY[-1, :], 'b-')
pylab.title('Coordinates on target')
#print "oiajfdoijadsf"
errorIMG = targetIMGToTemplate - templateIMG
LKCost = numpy.sum(errorIMG * templateWeight * errorIMG)
# find out if any coordinates are not in the mask
if targetIMGMask != None:
T = CCSegUtils.interp2q(numpy.arange(1, targetIMG.shape[1] + 1), numpy.arange(1, targetIMG.shape[0] + 1), targetIMGMask, TX, TY, extrapval = 0)
if numpy.any(T == 0):
LKCost = numpy.inf
return (targetIMGToTemplate, TX, TY, errorIMG, LKCost)
开发者ID:chrisadamsonmcri,项目名称:CCSegThickness,代码行数:27,代码来源:LKTracker.py
示例18: barGraphTwo
def barGraphTwo(xs1, fs1, xs2, fs2, f, xlabel, ylabel, legend):
pylab.cla()
bar1= pylab.bar(xs1, fs1, width=1, facecolor='red')
bar2=pylab.bar(xs2, fs2, width=1, facecolor='cyan')
# got from http://stackoverflow.com/questions/2194299/in-matplotlib-how-to-draw-a-bar-graphs-of-multiple-datasets-to-put-smallest-bars
all_patches = pylab.axes().patches
patch_at_x = {}
for patch in all_patches:
if patch.get_x() not in patch_at_x: patch_at_x[patch.get_x()] = []
patch_at_x[patch.get_x()].append(patch)
# custom sort function, in reverse order of height
def yHeightSort(i,j):
if j.get_height() > i.get_height(): return 1
else: return -1
# loop through sort assign z-order based on sort
for x_pos, patches in patch_at_x.iteritems():
if len(patches) == 1: continue
patches.sort(cmp=yHeightSort)
[patch.set_zorder(patches.index(patch)) for patch in patches]
fontP = FontProperties()
fontP.set_size('small')
#pylab.xlim([0,24])
pylab.ylabel(ylabel)
pylab.xlabel(xlabel)
pylab.legend((bar2[0], bar1[0]), legend, prop = fontP)
pylab.savefig(f)
开发者ID:jiahuang,项目名称:Statisddit,代码行数:30,代码来源:graph.py
示例19: updatePlot
def updatePlot(G, position, spinUp, spinDown, upColor, downColor, ax, E, step):
"""
Updates plot of network for viewing MC moves.
"""
pl.cla()
position = nx.circular_layout(G)
nx.draw_networkx_nodes(G,position, nodelist=spinUp,
node_color=upColor)
nx.draw_networkx_nodes(G,position, nodelist=spinDown,
node_color=downColor)
nx.draw_networkx_edges(G,position)
nx.draw_networkx_labels(G,position)
ax.text(-0.1, 0.98, 'Spin Up', style='italic',
bbox={'facecolor':upColor, 'alpha':0.9, 'pad':10})
ax.text(-0.1, 1.1, 'Spin Down', style='italic',color='White',
bbox={'facecolor':downColor, 'alpha':0.9, 'pad':10})
if E:
os.chdir('./data/')
if os.path.exists('./animate'):
pass
else:
os.mkdir('./animate/')
os.chdir('./animate/')
pl.savefig('animate_'+str(step)+'.png')
os.chdir('../..')
pl.draw()
开发者ID:mtgraves,项目名称:NetworkIsing,代码行数:28,代码来源:netIsingDriver.py
示例20: barGraph
def barGraph(xs1, fs1, f, xlabel, ylabel):
pylab.cla()
pylab.bar(xs1, fs1, width=0.8, facecolor='blue')
pylab.xlim([0,24])
pylab.ylabel(ylabel)
pylab.xlabel(xlabel)
pylab.savefig(f)
开发者ID:jiahuang,项目名称:Statisddit,代码行数:7,代码来源:graph.py
注:本文中的pylab.cla函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论