本文整理汇总了Python中pylab.xlim函数的典型用法代码示例。如果您正苦于以下问题:Python xlim函数的具体用法?Python xlim怎么用?Python xlim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xlim函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: plot_frontier
def plot_frontier(self,frontier_only=False,plot_samples=True) :
""" Plot the frontier"""
frontier = self.frontier
frontier_energy = self.frontier_energy
feat1,feat2 = self.feats
pl.figure()
if not frontier_only :
ll_list1,ll_list2 = zip(*self.all_seq_energy)
pl.plot(ll_list1,ll_list2,'b*')
if plot_samples :
ll_list1,ll_list2 = zip(*self.sample_seq_energy)
pl.plot(ll_list1,ll_list2,'g*')
pl.plot(*zip(*sorted(frontier_energy)),color='magenta',\
marker='*', linestyle='dashed')
ctr = dict(zip(set(frontier_energy),[0]*
len(set(frontier_energy))))
for i,e in enumerate(frontier_energy) :
ctr[e] += 1
pl.text(e[0],e[1]+0.1*ctr[e],str(i),fontsize=10)
pl.text(e[0]+0.4,e[1]+0.1*ctr[e],frontier[i],fontsize=9)
pl.xlabel('Energy:'+feat1)
pl.ylabel('Energy:'+feat2)
pl.title('Energy Plot')
xmin,xmax = pl.xlim()
ymin,ymax = pl.ylim()
pl.xlim(xmin,xmax)
pl.ylim(ymin,ymax)
pic_dir = '../docs/tex/pics/'
pl.savefig(pic_dir+self.name+'.pdf')
pl.savefig(pic_dir+self.name+'.png')
开发者ID:smoitra87,项目名称:pareto-hmm,代码行数:32,代码来源:exp1.py
示例2: plot_sphere_x
def plot_sphere_x( s, fname ):
""" put plot of ionization fractions from sphere `s` into fname """
plt.figure()
s.Edges.units = 'kpc'
s.r_c.units = 'kpc'
xx = s.r_c
L = s.Edges[-1]
plt.plot( xx, np.log10( s.xHe1 ),
color='green', ls='-', label = r'$x_{\rm HeI}$' )
plt.plot( xx, np.log10( s.xHe2 ),
color='green', ls='--', label = r'$x_{\rm HeII}$' )
plt.plot( xx, np.log10( s.xHe3 ),
color='green', ls=':', label = r'$x_{\rm HeIII}$' )
plt.plot( xx, np.log10( s.xH1 ),
color='red', ls='-', label = r'$x_{\rm HI}$' )
plt.plot( xx, np.log10( s.xH2 ),
color='red', ls='--', label = r'$x_{\rm HII}$' )
plt.xlim( -L/20, L+L/20 )
plt.xlabel( 'r_c [kpc]' )
plt.ylim( -4.5, 0.2 )
plt.ylabel( 'log 10 ( x )' )
plt.grid()
plt.legend(loc='best', ncol=2)
plt.tight_layout()
plt.savefig( 'doc/img/x_' + fname )
开发者ID:galtay,项目名称:rabacus,代码行数:31,代码来源:make_doc_images_bgnd_sphere.py
示例3: geweke_plot
def geweke_plot(data, name, format='png', suffix='-diagnostic', path='./', fontmap = None,
verbose=1):
# Generate Geweke (1992) diagnostic plots
if fontmap is None: fontmap = {1:10, 2:8, 3:6, 4:5, 5:4}
# Generate new scatter plot
figure()
x, y = transpose(data)
scatter(x.tolist(), y.tolist())
# Plot options
xlabel('First iteration', fontsize='x-small')
ylabel('Z-score for %s' % name, fontsize='x-small')
# Plot lines at +/- 2 sd from zero
pyplot((nmin(x), nmax(x)), (2, 2), '--')
pyplot((nmin(x), nmax(x)), (-2, -2), '--')
# Set plot bound
ylim(min(-2.5, nmin(y)), max(2.5, nmax(y)))
xlim(0, nmax(x))
# Save to file
if not os.path.exists(path):
os.mkdir(path)
if not path.endswith('/'):
path += '/'
savefig("%s%s%s.%s" % (path, name, suffix, format))
开发者ID:CosmologyTaskForce,项目名称:pymc,代码行数:29,代码来源:Matplot.py
示例4: rmsdSpreadSubplot
def rmsdSpreadSubplot(multiplier=1.0, layout=(-1, -1)):
rmsd_data = dict( (e, rad_data[e]['innov'][quant]) for e in rad_data.iterkeys() )
spread_data = dict( (e, rad_data[e]['spread'][quant]) for e in rad_data.iterkeys() )
times = temp.getTimes()
n_t = len(times)
for exp, exp_name in exp_names.iteritems():
pylab.plot(sawtooth(times, times)[:(n_t + 1)], rmsd_data[exp][:(n_t + 1)], color=colors[exp], linestyle='-')
pylab.plot(times[(n_t / 2):], rmsd_data[exp][n_t::2], color=colors[exp], linestyle='-')
for exp, exp_name in exp_names.iteritems():
pylab.plot(sawtooth(times, times)[:(n_t + 1)], spread_data[exp][:(n_t + 1)], color=colors[exp], linestyle='--')
pylab.plot(times[(n_t / 2):], spread_data[exp][n_t::2], color=colors[exp], linestyle='--')
ylim = pylab.ylim()
pylab.plot(times, -1 * np.ones((len(times),)), color='#999999', linestyle='-', label="RMS Innovation")
pylab.plot(times, -1 * np.ones((len(times),)), color='#999999', linestyle='--', label="Spread")
pylab.axhline(y=7, color='k', linestyle=':')
pylab.axvline(x=14400, color='k', linestyle=':')
pylab.ylabel("RMS Innovation/Spread (dBZ)", size='large')
pylab.xlim(times[0], times[-1])
pylab.ylim(ylim)
pylab.legend(loc=4)
pylab.xticks(times[::2], [ "" for t in times[::2] ])
pylab.yticks(size='x-large')
return
开发者ID:tsupinie,项目名称:research,代码行数:32,代码来源:plot_obs_space.py
示例5: plotB3reg
def plotB3reg():
w=loadStanFit('revE2B3BHreg.fit')
printCI(w,'mmu')
printCI(w,'mr')
for b in range(2):
subplot(1,2,b+1)
plt.title('')
px=np.array(np.linspace(-0.5,0.5,101),ndmin=2)
a0=np.array(w['mmu'][:,b],ndmin=2).T
a1=np.array(w['mr'][:,b],ndmin=2).T
y=np.concatenate([sap(a0+a1*px,97.5,axis=0),sap(a0+a1*px[:,::-1],2.5,axis=0)])
x=np.squeeze(np.concatenate([px,px[:,::-1]],axis=1))
plt.plot(px[0,:],np.median(a0)+np.median(a1)*px[0,:],'red')
#plt.plot([-1,1],[0.5,0.5],'grey')
ax=plt.gca()
ax.set_aspect(1)
ax.add_patch(plt.Polygon(np.array([x,y]).T,alpha=0.2,fill=True,fc='red',ec='w'))
y=np.concatenate([sap(a0+a1*px,75,axis=0),sap(a0+a1*px[:,::-1],25,axis=0)])
ax.add_patch(plt.Polygon(np.array([x,y]).T,alpha=0.2,fill=True,fc='red',ec='w'))
man=np.array([-0.4,-0.2,0,0.2,0.4])
mus=[]
for m in range(len(man)):
mus.append(loadStanFit('revE2B3BH%d.fit'%m)['mmu'][:,b])
mus=np.array(mus).T
errorbar(mus,x=man)
ax.set_xticks(man)
plt.xlim([-0.5,0.5])
plt.ylim([-0.4,0.8])
#plt.xlabel('Manipulated Displacement')
if b==0:
plt.ylabel('Perceived Displacemet')
plt.gca().set_yticklabels([])
subplot_annotate()
plt.text(-1.1,-0.6,'Pivot Displacement',fontsize=8);
开发者ID:simkovic,项目名称:wolfpackRevisited,代码行数:34,代码来源:Evaluation.py
示例6: plotFeatureImportance
def plotFeatureImportance(featureImportance, title, originalImage=None, lim=0.06, colorate=None):
"""
originalImage : the index of the original image. If None, ignore
"""
indices = featureImportanceIndices(len(featureImportance), originalImage)
pl.figure()
pl.title(title)
if colorate is not None:
nbType = len(colorate)
X = [[] for i in range(nbType)]
Y = [[] for i in range(nbType)]
for j, f in enumerate(featureImportance):
X[j % nbType].append(j)
Y[j % nbType].append(f)
for i in range(nbType):
pl.bar(X[i], Y[i], align="center", label=colorate[i][0], color=colorate[i][1])
pl.legend()
else:
pl.bar(range(len(featureImportance)), featureImportance, align="center")
#pl.xticks(pl.arange(len(indices)), indices, rotation=-90)
pl.xlim([-1, len(indices)])
pl.ylabel("Feature importance")
pl.xlabel("Filter indices")
pl.ylim(0, lim)
pl.show()
开发者ID:jm-begon,项目名称:masterthesis,代码行数:25,代码来源:util.py
示例7: InitializePlot
def InitializePlot(self, goal_config):
self.fig = pl.figure()
lower_limits, upper_limits = self.boundary_limits
pl.xlim([lower_limits[0], upper_limits[0]])
pl.ylim([lower_limits[1], upper_limits[1]])
pl.plot(goal_config[0], goal_config[1], 'gx')
# Show all obstacles in environment
for b in self.robot.GetEnv().GetBodies():
if b.GetName() == self.robot.GetName():
continue
bb = b.ComputeAABB()
pl.plot([bb.pos()[0] - bb.extents()[0],
bb.pos()[0] + bb.extents()[0],
bb.pos()[0] + bb.extents()[0],
bb.pos()[0] - bb.extents()[0],
bb.pos()[0] - bb.extents()[0]],
[bb.pos()[1] - bb.extents()[1],
bb.pos()[1] - bb.extents()[1],
bb.pos()[1] + bb.extents()[1],
bb.pos()[1] + bb.extents()[1],
bb.pos()[1] - bb.extents()[1]], 'r')
pl.ion()
pl.show()
开发者ID:ardyadipta,项目名称:robot_autonomy,代码行数:26,代码来源:SimpleEnvironment.py
示例8: updatePlot
def updatePlot(self):
""" Updates the antenna config plot"""
self.sp_ax.clear()
self.sp_fig.clear()
row = self.slider.value()
self.spinner.setValue(row)
data_x = self.fits_data[row,0,0,0,:]
data_y = self.fits_data[row,0,0,1,:]
flagged_x = self.fits_flagged[row,0,0,0,:]
flagged_y = self.fits_flagged[row,0,0,1,:]
freqs = self.fits_freqs
tsys = self.fits_tsys[row,:]
#plt.plot(freqs, data_x)
plt.plot(freqs[flagged_x == 0], data_x[flagged_x == 0], color='#333333', label='Pol A [%2.1f Jy]'%tsys[0])
plt.plot(freqs[flagged_y == 0], data_y[flagged_y == 0], color='#CC0000', label='Pol B [%2.1f Jy]'%tsys[1])
plt.ylabel('%s [%s]'%(self.fits_data_name, self.fits_data_unit))
plt.xlabel('%s [%s]'%(self.fits_freq_type, self.fits_freq_unit))
plt.title('Beam %s: %s %s'%(self.fits_beam[row], self.fits_date[row], self.fits_time[row]))
plt.xlim(np.min(freqs[flagged_x == 0]), np.max(freqs[flagged_x == 0]))
plt.legend()
plt.show()
self.sp_fig.canvas.draw()
self.lab_info.setText(self.fits_filename)
开发者ID:telegraphic,项目名称:hipsr_viewer,代码行数:32,代码来源:hipsr-sdview_bak.py
示例9: draw
def draw(self):
print self.edgeno
pos = 0
dy = 8
edgeno = self.edgeno
edge = self.edges[edgeno]
edgeprev = self.edges[edgeno-1]
p = np.round(edge["top"](1024))
top = min(p+2*dy, 2048)
bot = min(p-2*dy, 2048)
self.cutout = self.flat[1][bot:top,:].copy()
pl.figure(1)
pl.clf()
start = 0
dy = 512
for i in xrange(2048/dy):
pl.subplot(2048/dy,1,i+1)
pl.xlim(start, start+dy)
if i == 0: pl.title("edge %i] %s|%s" % (edgeno,
edgeprev["Target_Name"], edge["Target_Name"]))
pl.subplots_adjust(left=.07,right=.99,bottom=.05,top=.95)
pl.imshow(self.flat[1][bot:top,start:start+dy], extent=(start,
start+dy, bot, top), cmap='Greys', vmin=2000, vmax=6000)
pix = np.arange(start, start+dy)
pl.plot(pix, edge["top"](pix), 'r', linewidth=1)
pl.plot(pix, edgeprev["bottom"](pix), 'r', linewidth=1)
pl.plot(edge["xposs_top"], edge["yposs_top"], 'o')
pl.plot(edgeprev["xposs_bot"], edgeprev["yposs_bot"], 'o')
hpp = edge["hpps"]
pl.axvline(hpp[0],ymax=.5, color='blue', linewidth=5)
pl.axvline(hpp[1],ymax=.5, color='red', linewidth=5)
hpp = edgeprev["hpps"]
pl.axvline(hpp[0],ymin=.5,color='blue', linewidth=5)
pl.axvline(hpp[1],ymin=.5,color='red', linewidth=5)
if False:
L = top-bot
Lx = len(edge["xposs"])
for i in xrange(Lx):
xp = edge["xposs"][i]
frac1 = (edge["top"](xp)-bot-1)/L
pl.axvline(xp,ymin=frac1)
for xp in edgeprev["xposs"]:
frac2 = (edgeprev["bottom"](xp)-bot)/L
pl.axvline(xp,ymax=frac2)
start += dy
开发者ID:themiyan,项目名称:MosfireDRP_Themiyan,代码行数:60,代码来源:Flats.py
示例10: plot_file_color
def plot_file_color(base, thin=True, start=0, size=14, save=False):
conf, track, pegs = load(base)
fig = pl.figure(figsize=(size,size*conf['top']/conf['wall']))
track = track[start:]
x = track[:,0]; y = track[:,1]
t = np.linspace(0,1,x.shape[0])
points = np.array([x,y]).transpose().reshape(-1,1,2)
segs = np.concatenate([points[:-1],points[1:]],axis=1)
lc = LineCollection(segs, linewidths=0.25, cmap=pl.cm.coolwarm)
lc.set_array(t)
pl.gca().add_collection(lc)
#pl.scatter(x, y, c=np.arange(len(x)),linestyle='-',cmap=pl.cm.coolwarm)
#pl.plot(track[-1000000:,0], track[-1000000:,1], '-', linewidth=0.0125, alpha=0.8)
for peg in pegs:
pl.gca().add_artist(pl.Circle(peg, conf['radius'], color='k', alpha=0.3))
pl.xlim(0, conf['wall'])
pl.ylim(0, conf['top'])
pl.xticks([])
pl.yticks([])
pl.tight_layout()
pl.show()
if save:
pl.savefig(base+".png", dpi=200)
开发者ID:mattbierbaum,项目名称:plinko,代码行数:26,代码来源:plotting.py
示例11: tracks_movie
def tracks_movie(base, skip=1, frames=500, size=10):
"""
A movie of each particle as a point
"""
conf, track, pegs = load(base)
fig = pl.figure(figsize=(size,size*conf['top']/conf['wall']))
plot = None
for t in xrange(1,max(frames, track.shape[1]/skip)):
tmp = track[:,t*skip,:]
if not ((tmp[:,0] > 0) & (tmp[:,1] > 0) & (tmp[:,0] < conf['wall']) & (tmp[:,1] < conf['top'])).any():
continue
if plot is None:
plot = pl.plot(tmp[:,0], tmp[:,1], 'k,', alpha=1.0, ms=0.1)[0]
pl.xticks([])
pl.yticks([])
pl.xlim(0,conf['wall'])
pl.ylim(0,conf['top'])
pl.tight_layout()
else:
plot.set_xdata(tmp[:,0])
plot.set_ydata(tmp[:,1])
pl.draw()
pl.savefig(base+'-movie-%05d.png' % (t-1))
开发者ID:mattbierbaum,项目名称:plinko,代码行数:26,代码来源:plotting.py
示例12: plotFreqVsGoodTuring
def plotFreqVsGoodTuring(counts, confidence=1.96, loglog=False):
"""
Draws a scatterplot of the empirical frequencies of the counted species
versus their Simple Good Turing smoothed values, in rank order. Depends on
pylab and matplotlib.
"""
import pylab
from matplotlib import rc
tot = float(sum(counts.values()))
freqs = dict([(species, cnt/tot) for species, cnt in counts.iteritems()])
sgt, p0 = simpleGoodTuringProbs(counts, confidence)
if loglog:
plotFunc = pylab.loglog
else:
plotFunc = pylab.plot
plotFunc(sorted(freqs.values(), reverse=True), 'kD', mfc='white',
label="Observed")
plotFunc(sorted(sgt.values(), reverse=True), 'k+',
label="Simple Good-Turing Estimate")
pylab.xlim(-0.5, len(freqs)+0.5)
pylab.xlabel("Rank")
pylab.ylabel("Frequency")
pylab.legend(numpoints=1)
开发者ID:panand,项目名称:Ling248_2016,代码行数:25,代码来源:sgt.py
示例13: plotVOI
def plotVOI(self,n,points,L,data,kern,temp1,temp2,a,m,path):
z=np.zeros(m)
for i in xrange(m):
z[i]=self.VOIfunc(n,points[i,:],L,data,kern,temp1,temp2,False,a,False)
fig=plt.figure()
fig.set_size_inches(21, 21)
plt.plot(points,z,'-')
plt.xlabel('x',fontsize=60)
Xp=data.Xhist[0:self._numberTraining,0]
pylab.plot(Xp,np.zeros(len(Xp))+0.00009,'o',color='red',markersize=40,label="Training point")
if n>0:
Xp=data.Xhist[self._numberTraining:self._numberTraining+n,0]
pylab.plot(Xp,np.zeros(len(Xp))+0.00009,'o',color='firebrick',markersize=40,label="Chosen point")
ax = plt.subplot(111)
box = ax.get_position()
ax.set_position([box.x0, box.y0+box.height*0.1, box.width, box.height*0.9])
# Put a legend to the right of the current axis
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.09),ncol=2,fontsize=50)
pylab.xlim([-0.5,0.5])
# plt.legend()
plt.savefig(os.path.join(path,'%d'%n+"VOI_n.pdf"))
plt.close(fig)
开发者ID:toscanosaul,项目名称:SBO,代码行数:26,代码来源:VOI.py
示例14: plot_prob_effector
def plot_prob_effector(sens, fpr, xmax=1, baserate=0.1):
"""Plots a line graph of P(effector|positive test) against
the baserate of effectors in the input set to the classifier.
The baserate argument draws an annotation arrow
indicating P(pos|+ve) at that baserate
"""
assert 0.1 <= xmax <= 1, "Max x axis value must be in range [0,1]"
assert 0.01 <= baserate <= 1, "Baserate annotation must be in range [0,1]"
baserates = pylab.arange(0, 1.05, xmax * 0.005)
probs = [p_correct_given_pos(sens, fpr, b) for b in baserates]
pylab.plot(baserates, probs, 'r')
pylab.title("P(eff|pos) vs baserate; sens: %.2f, fpr: %.2f" % (sens, fpr))
pylab.ylabel("P(effector|positive)")
pylab.xlabel("effector baserate")
pylab.xlim(0, xmax)
pylab.ylim(0, 1)
# Add annotation arrow
xpos, ypos = (baserate, p_correct_given_pos(sens, fpr, baserate))
if baserate < xmax:
if xpos > 0.7 * xmax:
xtextpos = 0.05 * xmax
else:
xtextpos = xpos + (xmax-xpos)/5.
if ypos > 0.5:
ytextpos = ypos - 0.05
else:
ytextpos = ypos + 0.05
pylab.annotate('baserate: %.2f, P(pos|+ve): %.3f' % (xpos, ypos),
xy=(xpos, ypos),
xytext=(xtextpos, ytextpos),
arrowprops=dict(facecolor='black', shrink=0.05))
else:
pylab.text(0.05 * xmax, 0.95, 'baserate: %.2f, P(pos|+ve): %.3f' % \
(xpos, ypos))
开发者ID:widdowquinn,项目名称:Teaching-EMBL-Plant-Path-Genomics,代码行数:35,代码来源:ex03.py
示例15: drunkTest
def drunkTest(numTrials = 1000):
#stepsTaken = [10, 100, 1000, 10000]
stepsTaken = 1000
for dClass in (UsualDrunk, ColdDrunk, EDrunk, PhotoDrunk, DDrunk):
#initialize field
field = Field()
origin = Location(0, 0)
# initialize drunk
drunk = dClass('Drunk')
field.addDrunk(drunk, origin)
x_pos, y_pos = [], [] # initialize to empty
x, y = 0.0, 0.0
for trial in range(numTrials): # trials
x, y = walkVector(field, drunk, stepsTaken)
x_pos.append(x)
y_pos.append(y)
#pylab.plot(x_pos, y_pos, 'ro', s=5,
# label = dClass.__name__)
pylab.scatter(x_pos, y_pos,s=5, color='red')
pylab.title(str(dClass))
pylab.xlabel('x')
pylab.grid()
pylab.xlim(-100, 100)
pylab.ylim(-100,100)
pylab.ylabel('y')
pylab.show()
开发者ID:lizhicao1986,项目名称:mit6-00-2,代码行数:31,代码来源:quizProb4.py
示例16: InitializePlot
def InitializePlot(self, goal_config): # default
self.fig = pl.figure()
pl.xlim([self.lower_limits[0], self.upper_limits[0]])
pl.ylim([self.lower_limits[1], self.upper_limits[1]])
pl.plot(goal_config[0], goal_config[1], "gx")
# Show all obstacles in environment
for b in self.robot.GetEnv().GetBodies():
if b.GetName() == self.robot.GetName():
continue
bb = b.ComputeAABB()
pl.plot(
[
bb.pos()[0] - bb.extents()[0],
bb.pos()[0] + bb.extents()[0],
bb.pos()[0] + bb.extents()[0],
bb.pos()[0] - bb.extents()[0],
bb.pos()[0] - bb.extents()[0],
],
[
bb.pos()[1] - bb.extents()[1],
bb.pos()[1] - bb.extents()[1],
bb.pos()[1] + bb.extents()[1],
bb.pos()[1] + bb.extents()[1],
bb.pos()[1] - bb.extents()[1],
],
"r",
)
pl.ion()
pl.show()
开发者ID:ChunyangSun,项目名称:PlanningWithCost,代码行数:31,代码来源:SimpleEnvironment.py
示例17: 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()
开发者ID:OpenSourceCancer,项目名称:cancersim,代码行数:7,代码来源:quick_test_sim.py
示例18: plot_spectrum
def plot_spectrum():
#get the data...
a_0=struct.unpack('>1024l',fpga.read('even',1024*4,0))
a_1=struct.unpack('>1024l',fpga.read('odd',1024*4,0))
interleave_a=[]
for i in range(1024):
interleave_a.append(a_0[i])
interleave_a.append(a_1[i])
pylab.figure(num=1,figsize=(10,10))
pylab.ioff()
pylab.plot(interleave_a)
#pylab.semilogy(interleave_a)
pylab.title('Integration number %i.'%prev_integration)
pylab.ylabel('Power (arbitrary units)')
pylab.grid()
pylab.xlabel('Channel')
pylab.xlim(0,2048)
pylab.ioff()
pylab.hold(False)
pylab.show()
pylab.draw()
开发者ID:Vereese,项目名称:tutorials_devel,代码行数:25,代码来源:spectrometer.py
示例19: correlation_matrix
def correlation_matrix(data, size=8.0):
""" Calculates and shows the correlation matrix of the pandas data frame
'data' as a heat map.
Only the correlations between numerical variables are calculated!
"""
# calculate the correlation matrix
corr = data.corr()
#print corr
lc = len(corr.columns)
# set some settings for plottin'
pl.pcolor(corr, vmin = -1, vmax = 1, edgecolor = "black")
pl.colorbar()
pl.xlim([-5,lc])
pl.ylim([0,lc+5])
pl.axis('off')
# anotate the rows and columns with their corresponding variables
ax = pl.gca()
for i in range(0,lc):
ax.annotate(corr.columns[i], (-0.5, i+0.5), \
size='large', horizontalalignment='right', verticalalignment='center')
ax.annotate(corr.columns[i], (i+0.5, lc+0.5),\
size='large', rotation='vertical',\
horizontalalignment='center', verticalalignment='right')
# change the size of the image
fig = pl.figure(num=1)
fig.set_size_inches(size+(size/4), size)
pl.show()
开发者ID:ThomasvanHeyningen,项目名称:BestMLGroup2,代码行数:28,代码来源:ExploringData.py
示例20: plot_importances
def plot_importances(imp, clfName, obj):
imp=np.vstack(imp)
print imp
mean_importance = np.mean(imp,axis=0)
std_importance = np.std(imp,axis=0)
indices = np.argsort(mean_importance)[::-1]
print indices
print featureNames
featureList = []
# num_features = len(featureNames)
print("Feature ranking:")
for f in range(num_features):
featureList.append(featureNames[indices[f]])
print("%d. feature %s (%.2f)" % (f, featureNames[indices[f]], mean_importance[indices[f]]))
fig = pl.figure(figsize=(8,6),dpi=150)
pl.title("Feature importances",fontsize=30)
pl.bar(range(num_features), mean_importance[indices],
yerr = std_importance[indices], color=paired[0], align="center",
edgecolor=paired[0],ecolor=paired[1])
pl.xticks(range(num_features), featureList, size=15,rotation=90)
pl.ylabel("Importance",size=30)
pl.yticks(size=20)
pl.xlim([-1, num_features])
# fix_axes()
pl.tight_layout()
save_path = 'plots/'+obj+'/'+clfName+'_feature_importances.pdf'
fig.savefig(save_path)
开发者ID:rexshihaoren,项目名称:MSPrediction-Python,代码行数:27,代码来源:EnjoyLifePred.py
注:本文中的pylab.xlim函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论