本文整理汇总了Python中pylab.ioff函数的典型用法代码示例。如果您正苦于以下问题:Python ioff函数的具体用法?Python ioff怎么用?Python ioff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ioff函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
def prepare(self):
def setField(name):
self.xData = data[name].dimensions[0]
self.yData = data[name]
pylab.xlabel(data[name].dimensions[0].label)
pylab.ylabel(data[name].label)
pylab.ioff()
pylab.figure()
data = self.dataContainer
if self.dataContainer.numberOfColumns() > 2:
if u"Smoothed Absorption" in data.longnames.keys():
setField(u"Smoothed Absorption")
elif u"Absorption" in data.longnames.keys():
setField(u"Absorption")
else:
self.xData = data[u"Wellenlänge[nm]"]
self.yData = data[u"ScopRaw[counts]"]
pylab.ylabel("Scop Raw / a.u.")
else:
self.xData = self.dataContainer[0]
self.yData = self.dataContainer[1]
for i in xrange(len(self.xData.data)):
self.ordinates.append(self.yData.data[i])
self.abscissae.append(self.xData.data[i])
if u"Minima" in data.longnames.keys():
mins = data[u"Minima"]
for i in xrange(len(mins.data)):
self.mins.append(mins.data[i])
pylab.xlabel("Wavelength $\lambda$ / nm")
pylab.title(self.dataContainer.longname)
示例2: hinton
def hinton(W, maxWeight=None):
"""
Source: http://wiki.scipy.org/Cookbook/Matplotlib/HintonDiagrams
Draws a Hinton diagram for visualizing a weight matrix.
Temporarily disables matplotlib interactive mode if it is on,
otherwise this takes forever.
"""
reenable = False
if pl.isinteractive():
pl.ioff()
pl.clf()
height, width = W.shape
if not maxWeight:
maxWeight = 2**np.ceil(np.log(np.max(np.abs(W)))/np.log(2))
pl.fill(np.array([0,width,width,0]),np.array([0,0,height,height]),'gray')
pl.axis('off')
pl.axis('equal')
for x in xrange(width):
for y in xrange(height):
_x = x+1
_y = y+1
w = W[y,x]
if w > 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,w/maxWeight),'white')
elif w < 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,-w/maxWeight),'black')
if reenable:
pl.ion()
pl.show()
示例3: finalize
def finalize(self):
"""
Wraps up plotting by switching off interactive model and showing the
plot.
"""
plt.ioff()
plt.show()
示例4: plotSpectrum
def plotSpectrum(self,spectrum,title):
fig=plt.figure(figsize=self.figsize, dpi=self.dpi);plt.ioff()
index, bar_width = spectrum.index.values,0.2
for i in range(spectrum.shape[1]):
plt.bar(index + i*bar_width, spectrum.icol(i).values, bar_width, color=mpl.cm.jet(1.*i/spectrum.shape[1]), label=spectrum.columns[i])
plt.xlabel('Allele') ;plt.xticks(index + 3*bar_width, index) ;plt.legend();
plt.title('Figure {}. {}'.format(self.fignumber, title),fontsize=self.titleSize); self.pdf.savefig(fig);self.fignumber+=1
示例5: saveHintonDiagram
def saveHintonDiagram(W, directory):
maxWeight = None
#print "Weight: ", W
"""
Draws a Hinton diagram for visualizing a weight matrix.
Temporarily disables matplotlib interactive mode if it is on,
otherwise this takes forever.
"""
reenable = False
if pylab.isinteractive():
pylab.ioff()
pylab.clf()
height, width = W.shape
if not maxWeight:
maxWeight = 2**numpy.ceil(numpy.log(numpy.max(numpy.abs(W)))/numpy.log(2))
pylab.fill(numpy.array([0,width,width,0]),numpy.array([0,0,height,height]),'gray')
pylab.axis('off')
pylab.axis('equal')
for x in xrange(width):
for y in xrange(height):
_x = x+1
_y = y+1
w = W[y,x]
if w > 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,w/maxWeight),'white')
elif w < 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,-w/maxWeight),'black')
if reenable:
pylab.ion()
#pylab.show()
pylab.savefig(directory)
示例6: hinton
def hinton(W, maxWeight=None):
"""
Draws a Hinton diagram for visualizing a weight matrix.
Temporarily disables matplotlib interactive mode if it is on,
otherwise this takes forever.
"""
reenable = False
if P.isinteractive():
P.ioff()
P.clf()
height, width = W.shape
if not maxWeight:
maxWeight = 2**N.ceil(N.log(N.max(N.abs(W)))/N.log(2))
P.fill(N.array([0,width,width,0]),N.array([0,0,height,height]),'gray')
P.axis('off')
P.axis('equal')
for x in xrange(width):
for y in xrange(height):
_x = x+1
_y = y+1
w = W[y,x]
if w > 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,w/maxWeight),'white')
elif w < 0:
_blob(_x - 0.5, height - _y + 0.5, min(1,-w/maxWeight),'black')
if reenable:
P.ion()
P.show()
示例7: plotOutput
def plotOutput(X,Y,spectrumLabel,ydata,PBool=True,ydataBool=False,residuals=False,path=False):
"""Plots the program outputs for the user"""
import matplotlib
if PBool == False:
matplotlib.use('Agg') #non-interactive backend
import pylab as P
P.ioff() #Ensure interactivity mode is off so that graph does not dissapear immediately
fig = P.figure()
maxYval = amax(Y)
minYval = amin(Y)
DynamicRange = maxYval - minYval
if not ydataBool:
P.plot(X,Y,'g', linewidth = 2.0)
P.xlabel(r'Detuning (GHz)')
P.ylabel(spectrumLabel)
P.xlim(X[0],X[-1])
P.ylim(minYval-0.02*DynamicRange,maxYval+0.02*DynamicRange)
else:
ax1 = fig.add_axes([0.15,0.30,0.75,0.65])
ax1.plot(X,ydata,'k')
ax1.plot(X,Y,'r--', linewidth=1.8)
ax1.set_xlim(X[0],X[-1])
ax1.set_ylim(minYval-0.02*DynamicRange,maxYval+0.02*DynamicRange)
ax1.set_xticklabels([])
P.ylabel(spectrumLabel)
ax2 = fig.add_axes([0.15,0.10,0.75,0.15])
ax2.plot(X,residuals*100.0,'k')
ax2.set_xlim(X[0],X[-1])
ax2.axhline(color='r', linestyle = '--', linewidth=1.8)
P.xlabel(r'Detuning (GHz)')
P.ylabel(r'Residuals $(\times 100)$')
if path:
P.savefig(path)
if PBool:
P.show()
示例8: __call__
def __call__(self,output_fn,init_time=0,final_time=None,**params):
p=ParamOverrides(self,params)
if final_time is None:
final_time=topo.sim.time()
attrs = p.attrib_names if len(p.attrib_names)>0 else output_fn.attrib_names
for a in attrs:
pylab.figure(figsize=(6,4))
isint=pylab.isinteractive()
pylab.ioff()
pylab.grid(True)
ylabel=p.ylabel
pylab.ylabel(a+" "+ylabel)
pylab.xlabel('Iteration Number')
coords = p.units if len(p.units)>0 else output_fn.units
for coord in coords:
y_data=[y for (x,y) in output_fn.values[a][coord]]
x_data=[x for (x,y) in output_fn.values[a][coord]]
if p.raw==True:
plot_data=zip(x_data,y_data)
pylab.save(normalize_path(p.filename+a+'(%.2f, %.2f)' %(coord[0], coord[1])),plot_data,fmt='%.6f', delimiter=',')
pylab.plot(x_data,y_data, label='Unit (%.2f, %.2f)' %(coord[0], coord[1]))
(ymin,ymax)=p.ybounds
pylab.axis(xmin=init_time,xmax=final_time,ymin=ymin,ymax=ymax)
if isint: pylab.ion()
pylab.legend(loc=0)
p.title=topo.sim.name+': '+a
p.filename_suffix=a
self._generate_figure(p)
示例9: plot_transform
def plot_transform(X):
pylab.ion()
pylab.figure()
pylab.imshow(scipy.log(X.T), origin='lower', aspect='auto', interpolation='nearest', norm=matplotlib.colors.Normalize())
pylab.xlabel('Window index')
pylab.ylabel('Transform coefficient')
pylab.ioff()
示例10: plotChromosome
def plotChromosome(DF, fname=None, colors=['black', 'gray'], markerSize=20, ylim=None, show=True, scale=3):
if not show:
plt.ioff()
if 'POS' not in DF.columns:
df=DF.reset_index()
else:
df=DF
def plotOne(b, d, name):
a = b.dropna()
c = d.loc[a.index]
plt.scatter(a.index, a, s=markerSize, c=c, alpha=0.8, edgecolors='none')
th = a.mean() + scale * a.std()
outliers = a[a > th]
# outliers=findOutliers(a)
if len(outliers):
plt.scatter(outliers.index, outliers, s=markerSize, c='r', alpha=0.8, edgecolors='none')
plt.axhline(th, color='blue')
plt.axis('tight');
# plt.xlim(0, a.index[-1]);
plt.ylabel(name)
# plt.setp(plt.gca().get_xticklabels(), visible=False)
if ylim is not None: plt.ylim(ymin=ylim)
df['gpos'] = df.POS
df['color'] = 'gray'
df.set_index('gpos', inplace=True);
df.sort_index(inplace=True)
plt.figure(figsize=(24, 16), dpi=60);
# plt.subplot(3,1,1)
df.color='g'
plotOne(df.icol(1), df.color, 'COMALE')
df.color='b'
plotOne(df.icol(2), df.color, 'COMALE')
示例11: arrange_figures
def arrange_figures(layout=None, screen=2, xgap=10,
ygap=30, offset=0, figlist=None):
"""Automatiskt arrangera alla figurer i ett icke overlappande
monster
*layout*
Anvands inte just nu
*screen* [=2]
anger vilken skarm man i forsta hand vill ha fonstren pa.
*xgap*
Gap i x-led mellan fonster
*ygap*
Gap i y-led mellan fonster
*offset*
Nar skarmen ar fylld borjar man om fran ovre hogra hornet
men med en offset i x och y led.
*figlist*
Lista med figurnummer som skall arrangeras
"""
#Hamta information om total skarmbredd over alla anslutna skarmar
if not is_in_ipython():
return
# pylab.show()
pylab.ioff()
x0 = 0 + offset
y0 = 0 + offset
if screen == 2:
x0 = (pylab.get_current_fig_manager().window.winfo_screenwidth() +
offset)
if figlist is None:
figlist = sorted([x for x in Gcf.figs.items()])
x = x0
y = y0
maxheight = 0
while figlist:
fig = _, f = figlist[0]
figlist = figlist[1:]
if fig_fits_w(f, x):
move_fig(f, x, y)
x = x + f.window.winfo_width() + xgap
maxheight = max(maxheight, f.window.winfo_height())
else:
x = x0
y = y + maxheight + ygap
maxheight = 0
if fig_fits_h(f, y):
move_fig(f, x, y)
x = x + f.window.winfo_width() + xgap
else:
arrange_figures(offset=DELTAOFFSET, xgap=xgap, ygap=ygap,
screen=screen, figlist=[fig] + figlist)
break
pylab.ion()
示例12: main
def main(argv):
[ data_file ] = argv
pylab.ioff()
led_readings = {}
with open(data_file) as f:
for line in f:
record = json.loads(line)
leds = record['leds']
if (len(leds) == 1):
led = leds[0];
ts = record['timestamp'] / 1000.0
ts = datetime.fromtimestamp(ts).strftime('%d-%m-%Y %H:%M:%S')
if led not in led_readings:
led_readings[led] = {}
led_readings[led][ts] = record['light']
for led, readings in sorted(led_readings.items()):
ts = readings.keys()
photo_res_1 = [int(photo_res['0']) for photo_res in readings.values()]
x = range(len(ts))
pyplot.plot(x, photo_res_1)
pylab.xticks(x, ts, rotation=45)
pylab.savefig('/tmp/plots/' + str(led) + '_1.png')
示例13: plot
def plot(self,pstyle="-"):
import pylab;
pfig=XpyFigure(pylab.gcf().number);
if isstring(pstyle):
pstyle=XyPlotStyle(pstyle);
i=0;
pylab.ioff();
#print "ioff"
for k in self.keys():
p=self[k];
if self.get('_datobj_title') is not None:
p['title']=self.get('_datobj_title');
#print "p type",type(p)
pstyle['linename']=k;
if i==0:
pstyle['showlabels']=True;
else:
pstyle['showlabels']=False;
p.plot(pstyle);
if i==0:
pylab.hold(True);
pstyle.nextplotstyle();
i=i+1;
pylab.ion();
pylab.grid(True);
stdout( "plotabledataobjtable:plot, done.")
示例14: profile
def profile():
pylab.figure()
pylab.ion()
for i, ccol in enumerate(chart):
R, G, B, tX, tY, tZ = ccol
tx, ty = toxyY(tX, tY, tZ)
setAndroidColor(R, G, B)
X, Y, Z, x, y = getXYZxy()
print i, len(chart)
print R, G, B, tX, tY, tZ, X, Y, Z
pylab.plot(tx, ty, "go")
pylab.plot(x, y, "rx")
pylab.xlim([0, 0.8])
pylab.ylim([0, 0.9])
pylab.axis("scaled")
pylab.draw()
pylab.show()
pylab.ioff()
pylab.show()
示例15: promt
def promt(self, x, y):
p = Plot()
p.error(x, y, ecolor='0.3')
p.make()
pylab.ion()
p.show()
pylab.ioff()
print(' *** RANGE PICKER for "{}":'.format(self.id))
if RPicker.storage is not None and self.id in RPicker.storage:
r = RPicker.storage[self.id]
print(' previously from {:.5g} to {:.5g}'.format(r[0], r[1]))
xunit = p._xaxis.sprefunit()
lower = input(' lower limit ({}) = '.format(xunit))
upper = input(' upper limit ({}) = '.format(xunit))
print('')
lower = float(lower)
upper = float(upper)
f = Quantity(xunit) / Quantity(unit=x.uvec)
f = float(f)
lower *= f
upper *= f
if RPicker.storage is not None:
RPicker.storage[self.id] = (lower, upper)
print(' stored...')
return lower, upper