本文整理汇总了Python中pylab.cla函数的典型用法代码示例。如果您正苦于以下问题:Python cla函数的具体用法?Python cla怎么用?Python cla使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cla函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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
示例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()
示例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")
示例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()
示例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()
示例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)
示例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
示例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
示例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()
示例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()
示例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
示例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()
示例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
示例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()