本文整理汇总了Python中pylab.draw函数的典型用法代码示例。如果您正苦于以下问题:Python draw函数的具体用法?Python draw怎么用?Python draw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了draw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run():
colors = [
'b', 'g', 'r', 'c', 'm', 'y', 'k',
'b--', 'g--', 'r--', 'c--', 'm--', 'y--', 'k--',
'bo', 'go', 'ro', 'co', 'mo', 'yo', 'ko',
'b+', 'g+', 'r+', 'c+', 'm+', 'y+', 'k+',
'b*', 'g*', 'r*', 'c*', 'm*', 'y*', 'k*',
'b|', 'g|', 'r|', 'c|', 'm|', 'y|', 'k|',
]
plots = defaultdict(list)
heap_size = []
order = ['Heap change']
manager = pylab.get_current_fig_manager()
manager.resize(1400, 1350)
pylab.ion()
for entry in read_data():
heap_size.append(entry["after"]["size_bytes"])
pylab.subplot(2, 1, 1)
pylab.plot(heap_size, 'r', label='Heap size')
pylab.legend(["Heap size"], loc=2)
pylab.subplot(2, 1, 2)
plots["Heap change"].append(entry["change"]["size_bytes"])
for thing in entry["change"]["details"]:
if thing["what"] not in order:
order.append(thing["what"])
plots[thing["what"]].append(thing["size_bytes"])
for what, color in zip(order, colors):
pylab.plot(plots[what], color, label=what)
pylab.legend(order, loc=3)
pylab.draw()
示例2: createPlot
def createPlot(dataY, dataX, ticksX, annotations, axisY, axisX, dostep, doannotate):
if not ticksX:
ticksX = dataX
if dostep:
py.step(dataX, dataY, where='post', linestyle='-', label=axisY) # where=post steps after point
else:
py.plot(dataX, dataY, marker='o', ms=5.0, linestyle='-', label=axisY)
if annotations and doannotate:
for note, x, y in zip(annotations, dataX, dataY):
py.annotate(note, (x, y), xytext=(2,2), xycoords='data', textcoords='offset points')
py.xticks(np.arange(1, len(dataX)+1), ticksX, horizontalalignment='left', rotation=30)
leg = py.legend()
leg.draggable()
py.xlabel(axisX)
py.ylabel('time (s)')
# Set X axis tick labels as rungs
#print zip(dataX, dataY)
py.draw()
py.show()
return
示例3: plotLists
def plotLists(xList, xLabel=None, eListTitle=None, eList=None, eLabel=None, fListTitle=None, fList=None, fLabel=None):
if h2o.python_username!='kevin':
return
import pylab as plt
print "xList", xList
print "eList", eList
print "fList", fList
font = {'family' : 'normal',
'weight' : 'normal',
'size' : 26}
### plt.rc('font', **font)
plt.rcdefaults()
if eList:
if eListTitle:
plt.title(eListTitle)
plt.figure()
plt.plot (xList, eList)
plt.xlabel(xLabel)
plt.ylabel(eLabel)
plt.draw()
if fList:
if fListTitle:
plt.title(fListTitle)
plt.figure()
plt.plot (xList, fList)
plt.xlabel(xLabel)
plt.ylabel(fLabel)
plt.draw()
if eList or fList:
plt.show()
示例4: set_ticks
def set_ticks(xmajor,ymajor,xminor,yminor):
ax=pylab.gca()
ax.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(xmajor))
ax.xaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(xminor))
ax.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(ymajor))
ax.yaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(yminor))
pylab.draw()
示例5: drawPrfastscore
def drawPrfastscore(tp,fp,scr,tot,show=True):
tp=numpy.cumsum(tp)
fp=numpy.cumsum(fp)
rec=tp/tot
prec=tp/(fp+tp)
#dif=numpy.abs(prec[1:]-rec[1:])
dif=numpy.abs(prec[::-1]-rec[::-1])
pos=dif.argmin()
pos=len(dif)-pos-1
ap=0
for t in numpy.linspace(0,1,11):
pr=prec[rec>=t]
if pr.size==0:
pr=0
p=numpy.max(pr);
ap=ap+p/11;
if show:
pylab.plot(rec,prec,'-g')
pylab.title("AP=%.3f EPRthr=%.3f"%(ap,scr[pos]))
pylab.xlabel("Recall")
pylab.ylabel("Precision")
pylab.grid()
pylab.show()
pylab.draw()
return rec,prec,scr,ap,scr[pos]
示例6: update
def update(self):
if self.pose != []:
plt.figure(1)
clf()
self.fig1 = plt.figure(num=1, figsize=(self.window_size, \
self.window_size), dpi=80, facecolor='w', edgecolor='w')
title (self.title)
xlabel('Easting [m]')
ylabel('Northing [m]')
axis('equal')
grid (True)
poseT = zip(*self.pose)
pose_plt = plot(poseT[1],poseT[2],'#ff0000')
if self.wptnav != []:
mode = self.wptnav[-1][MODE]
if not (self.wptnav[-1][B_E] == 0 and self.wptnav[-1][B_N] == 0 and self.wptnav[-1][A_E] == 0 and self.wptnav[-1][A_N] == 0):
b_dot = plot(self.wptnav[-1][B_E],self.wptnav[-1][B_N],'ro',markersize=8)
a_dot = plot(self.wptnav[-1][A_E],self.wptnav[-1][A_N],'go',markersize=8)
ab_line = plot([self.wptnav[-1][B_E],self.wptnav[-1][A_E]],[self.wptnav[-1][B_N],self.wptnav[-1][A_N]],'g')
target_dot = plot(self.wptnav[-1][TARGET_E],self.wptnav[-1][TARGET_N],'ro',markersize=5)
if mode == -1:
pose_dot = plot(self.wptnav[-1][POSE_E],self.wptnav[-1][POSE_N],'b^',markersize=8)
elif mode == 1:
pose_dot = plot(self.wptnav[-1][POSE_E],self.wptnav[-1][POSE_N],'bs',markersize=8)
elif mode == 2:
pose_dot = plot(self.wptnav[-1][POSE_E],self.wptnav[-1][POSE_N],'bo',markersize=8)
if self.save_images:
self.fig1.savefig ('plot_map%05d.jpg' % self.image_count)
self.image_count += 1
draw()
示例7: run
def run(steps=10):
for i in range(steps):
Q.time_step()
#Q.plot_links()
py.xlim((0,config['XSIZE']))
py.ylim((0,config['YSIZE']))
py.draw()
示例8: plot
def plot(self):
if not self.plot_state: return
history = self.plot_state
import pylab
with self.pylab_interface:
dream_views.plot_Med(history)
pylab.draw()
示例9: plotSpectrum
def plotSpectrum(spectrum,filename=""):
pylab.ion()
pylab.figure(0)
pylab.clf()
pylab.plot(spectrum)
pylab.draw()
pylab.savefig(filename)
示例10: ukViz
def ukViz(fgi, axap, ap, axac, y):
axap.set_xdata(ap[1,:])
axap.set_ydata(ap[0,:])
axac.set_xdata(y[1,:])
axac.set_ydata(y[0,:])
plt.draw()
fgi.show()
示例11: gui_repr
def gui_repr(self):
"""Generate a GUI to represent the sentence alignments
"""
if __pylab_loaded__:
fig_width = max(len(self.text_e), len(self.text_f)) + 1
fig_height = 3
pylab.figure(figsize=(fig_width*0.8, fig_height*0.8), facecolor='w')
pylab.box(on=False)
pylab.subplots_adjust(left=0, right=1, bottom=0, top=1)
pylab.xlim(-1, fig_width - 1)
pylab.ylim(0, fig_height)
pylab.xticks([])
pylab.yticks([])
e = [0 for _ in xrange(len(self.text_e))]
f = [0 for _ in xrange(len(self.text_f))]
for (i, j) in self.align:
e[i] = 1
f[j] = 1
# draw the middle line
pylab.arrow(i, 2, j - i, -1, color='r')
for i in xrange(len(e)):
# draw e side line
pylab.text(i, 2.5, self.text_e[i], ha = 'center', va = 'center',
rotation=30)
if e[i] == 1:
pylab.arrow(i, 2.5, 0, -0.5, color='r', alpha=0.3, lw=2)
for i in xrange(len(f)):
# draw f side line
pylab.text(i, 0.5, self.text_f[i], ha = 'center', va = 'center',
rotation=30)
if f[i] == 1:
pylab.arrow(i, 0.5, 0, 0.5, color='r', alpha=0.3, lw=2)
pylab.draw()
示例12: save_plot
def save_plot(self, filename):
plt.ion()
targarr = np.array(self.targvalue)
self.posi[0].set_xdata(self.wt_positions[:,0])
self.posi[0].set_ydata(self.wt_positions[:,1])
while len(self.plotel)>0:
self.plotel.pop(0).remove()
self.plotel = self.shape_plot.plot(np.array([self.wt_positions[[i,j],0] for i, j in self.elnet_layout.keys()]).T,
np.array([self.wt_positions[[i,j],1] for i, j in self.elnet_layout.keys()]).T, 'y-', linewidth=1)
for i in range(len(self.posb)):
self.posb[i][0].set_xdata(self.iterations)
self.posb[i][0].set_ydata(targarr[:,i])
self.legend.texts[i].set_text('%s = %8.2f'%(self.targname[i], targarr[-1,i]))
self.objf_plot.set_xlim([0, self.iterations[-1]])
self.objf_plot.set_ylim([0.5, 1.2])
if not self.title == '':
plt.title('%s = %8.2f'%(self.title, getattr(self, self.title)))
plt.draw()
#print self.iterations[-1] , ': ' + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))])
with open(self.result_file+'.results','a') as f:
f.write( '%d:'%(self.inc) + ', '.join(['%s=%6.2f'%(self.targname[i], targarr[-1,i]) for i in range(len(self.targname))]) +
'\n')
#plt.show()
#plt.savefig(filename)
display(plt.gcf())
#plt.show()
clear_output(wait=True)
示例13: keypress
def keypress(event):
global pos,cb,fig,dataset,nticks,ticks,colors,cmap
if event.key==",":
pos -= 1
if event.key==".":
pos += 10
if event.key=="a":
nticks+=1
ticks=[i/float(nticks) for i in range(nticks)]
colors=[float2rgb(sqrt(i+1),mic,mxc) for i in range(len(ticks))]
if event.key=="z":
nticks-=1
ticks=[i/float(nticks) for i in range(nticks)]
colors=[float2rgb(sqrt(i+1),mic,mxc) for i in range(len(ticks))]
pos=pos%gridsz[0]
if pstyle==1:
ax=logplotter(X,Y,dataset[pos,:,:],ticks,colors)
pl.title("%d Log plot energy density, use < and > to change plots"%pos)
#P.colorbar(ax,ticks=ticks,drawedges=True)
cb.update_bruteforce(ax)
elif pstyle==2:
plotter(X,Y,dataset[pos,:,:])
pl.title("%d Vacancy in Red, use < and > to change plots"%pos)
elif pstyle==3:
pl.imshow(dataset[pos,:,:],extent=[0,gridsz[0],0,gridsz[1]],cmap=cmap)
pl.draw()
示例14: PSFrange
def PSFrange(self,junkAx):
"""
Display function that you shouldn't call directly.
"""
#ca=pyl.gca()
pyl.sca(self.sp1)
print self.starsScat
newLim=[self.sp1.get_xlim(),self.sp1.get_ylim()]
self.psfPlotLimits=newLim[:]
w=num.where((self.points[:,0]>=self.psfPlotLimits[0][0])&(self.points[:,0]<=self.psfPlotLimits[0][1])&(self.points[:,1]>=self.psfPlotLimits[1][0])&(self.points[:,1]<=self.psfPlotLimits[1][1]))[0]
if self.starsScat<>None:
self.starsScat.remove()
self.starsScat=None
for ii in range(len(self.showing)):
if self.showing[ii]: self.moffPatchList[ii][0].remove()
for ii in range(len(self.showing)):
if ii not in w: self.showing[ii]=0
else: self.showing[ii]=1
for ii in range(len(self.showing)):
if self.showing[ii]:
self.moffPatchList[ii]=self.sp4.plot(self.moffr,self.moffs[ii])
self.sp4.set_xlim(0,30)
self.sp4.set_ylim(0,1.02)
pyl.draw()
示例15: plotSpectrum6
def plotSpectrum6(spectrum1On,spectrum2On,spectrum3On,spectrum4On,spectrum1Off,spectrum2Off,spectrum3Off,spectrum4Off,thetaL,thetaR,filename=""):
pylab.ion()
pylab.figure(0)
pylab.clf()
pylab.grid()
pylab.subplot(321)
pylab.plot(spectrum1On,'r')
pylab.plot(spectrum1Off)
pylab.title('Channel1')
pylab.subplot(322)
pylab.title('Channel2')
pylab.plot(spectrum2On,'r')
pylab.plot(spectrum2Off)
pylab.subplot(323)
pylab.title('Channel3')
pylab.plot(spectrum3On,'r')
pylab.plot(spectrum3Off)
pylab.subplot(324)
pylab.title('Channel4')
pylab.plot(spectrum4On,'r')
pylab.plot(spectrum4Off)
pylab.subplot(325)
pylab.title('ThetaL')
pylab.plot(thetaL,'r')
pylab.subplot(326)
pylab.title('ThetaR')
pylab.plot(thetaR,'r')
pylab.draw()
pylab.savefig(filename)