本文整理汇总了Python中pylab.yscale函数的典型用法代码示例。如果您正苦于以下问题:Python yscale函数的具体用法?Python yscale怎么用?Python yscale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yscale函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: mesh2d_mcolor_mask
def mesh2d_mcolor_mask(self, data, axis, output=None, mask=None, datscale='log',
axiscale=['log', 'log'], pcolors='Greys', maskcolors=None):
""" >>> generate 2D mesh plot <<<
"""
pl.clf()
fig=pl.figure()
ax=fig.add_subplot(111)
pldat=data
# get the color norm
if(datscale=='log'):
cnorm=colors.LogNorm()
elif(datscale=='linear'):
cnorm=colors.NoNorm()
else:
raise Exception
color1=colors.colorConverter.to_rgba('white')
color2=colors.colorConverter.to_rgba('blue')
color3=colors.colorConverter.to_rgba('yellow')
my_cmap0=colors.LinearSegmentedColormap.from_list('mycmap0',[color1, color1, color2, color2, color2, color3, color3], 512)
my_cmap0._init()
if pcolors!=None:
cm=ax.pcolormesh(axis[0,:], axis[1,:], pldat, cmap=pl.cm.get_cmap(pcolors),
norm=cnorm)
#cm=ax.pcolormesh(axis[0,:], axis[1,:], pldat, cmap=my_cmap0, norm=cnorm)
else:
cm=ax.pcolormesh(axis[0,:], axis[1,:], pldat, norm=cnorm)
if mask!=None:
# get the color map of mask
"""
color1=colors.colorConverter.to_rgba('white')
color2=colors.colorConverter.to_rgba('red')
my_cmap=colors.LinearSegmentedColormap.from_list('mycmap',[color1, color2], 512)
my_cmap._init()
alphas=np.linspace(0.2, 0.7, my_cmap.N+3)
my_cmap._lut[:,-1] = alphas
"""
maskdata=np.ma.masked_where((mask<=1e-2)&(mask>=-1e-2) , mask)
mymap=ax.contourf(axis[0,:], axis[1,:], maskdata, cmap=maskcolors)
cbar=fig.colorbar(mymap, ticks=[4, 6, 8]) #, orientation='horizontal')
cbar.ax.set_yticklabels(['void', 'filament', 'halo'])
pl.xscale(axiscale[0])
pl.yscale(axiscale[1])
return
开发者ID:astrofanlee,项目名称:project_TL,代码行数:60,代码来源:myplot.py
示例2: plot_charts2
def plot_charts2(data1, data2=None, xlabel=None, ylabel=None, size=(10, 4), log_scale=True):
plt.figure(figsize=size)
plt.grid()
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.plot(data1, color='blue', lw=2)
plt.plot(data1,
linestyle='None',
markerfacecolor='white',
markeredgecolor='blue',
marker='o',
markeredgewidth=2,
markersize=8)
if data2 is not None:
plt.plot(data2, color='red', lw=2)
plt.plot(data2,
linestyle='None',
markerfacecolor='white',
markeredgecolor='red',
marker='o',
markeredgewidth=2,
markersize=8)
if log_scale:
plt.yscale('log')
plt.xlim(-0.2, len(data1) + 0.2)
plt.ylim(0.8)
plt.show()
开发者ID:antworteffekt,项目名称:GraphLearn,代码行数:27,代码来源:draw.py
示例3: main
def main(k,m,x,v,t0,tf,dt):
xs=numpy.arange(t0,tf+dt/2,dt)
w2=k/m
ys1=[]
es1=[]
x1=x
v1=v
for i in xs:
#euler
vtemp=v1
v1=v1-w2*x1*dt
x1=x1+v1*dt
e1=(k*x1**2+m*v1**2)/2
ys1+=[x1]
es1+=[e1]
#pylab.plot(xs,ys1,'-',label='x(t) - Euler')
e0=(k*x**2+m*v**2)/2
incl=numpy.log(e1-e0)/(tf-t0)
pylab.plot(xs,es1,'-',label='E(t); dt=%f'%(dt))
pylab.xlabel('t')
pylab.ylabel('E')
pylab.yscale('log')
pylab.legend(loc=8)
for x,y1,e1 in zip(xs,ys1,es1):
print x, y1, e1
开发者ID:atilaromero,项目名称:metcompB,代码行数:25,代码来源:quest6.py
示例4: plot
def plot(self):
f = pylab.figure(figsize=(8,4))
co = [] #colors container
for zScore, r in itertools.izip(self.zScores, self.log2Ratio):
if zScore < self.pCut:
if r > 0:
co.append(Colors().greenColor)
elif r < 0:
co.append(Colors().redColor)
else:
raise Exception
else:
co.append(Colors().blueColor)
#print "Probability this is from a normal distribution: %.3e" %stats.normaltest(self.log2Ratio)[1]
ax = f.add_subplot(121)
pylab.axvline(self.meanLog2Ratio, color=Colors().redColor)
pylab.axvspan(self.meanLog2Ratio-(2*self.stdLog2Ratio),
self.meanLog2Ratio+(2*self.stdLog2Ratio), color=Colors().blueColor, alpha=0.2)
his = pylab.hist(self.log2Ratio, bins=50, color=Colors().blueColor)
pylab.xlabel("log2 Ratio %s/%s" %(self.sampleNames[1], self.sampleNames[0]))
pylab.ylabel("Frequency")
ax = f.add_subplot(122, aspect='equal')
pylab.scatter(self.genes1, self.genes2, c=co, alpha=0.5)
pylab.ylabel("%s RPKM" %self.sampleNames[1])
pylab.xlabel("%s RPKM" %self.sampleNames[0])
pylab.yscale('log')
pylab.xscale('log')
pylab.tight_layout()
开发者ID:TorHou,项目名称:gscripts,代码行数:30,代码来源:rpkmZ.py
示例5: _show_rates
def _show_rates(rate, wo, wt, attenuator, tau_NP, tau_P):
import pylab
#pylab.figure()
pylab.errorbar(rate, wt[0], yerr=wt[1], fmt='g.', label='attenuated')
pylab.errorbar(rate, wo[0], yerr=wo[1], fmt='b.', label='unattenuated')
pylab.xscale('log')
pylab.yscale('log')
pylab.xlabel('incident rate (counts/second)')
pylab.ylabel('observed rate (counts/second)')
pylab.legend(loc='best')
pylab.grid(True)
pylab.plot(rate, rate/attenuator, 'g-', label='target')
pylab.plot(rate, rate, 'b-', label='target')
Ipeak, Rpeak = peak_rate(tau_NP=tau_NP, tau_P=tau_P)
if rate[0] <= Ipeak <= rate[-1]:
pylab.axvline(x=Ipeak, ls='--', c='b')
pylab.text(x=Ipeak, y=0.05, s=' %g'%Ipeak,
ha='left', va='bottom',
transform=pylab.gca().get_xaxis_transform())
if False:
pylab.axhline(y=Rpeak, ls='--', c='b')
pylab.text(y=Rpeak, x=0.05, s=' %g\n'%Rpeak,
ha='left', va='bottom',
transform=pylab.gca().get_yaxis_transform())
开发者ID:reflectometry,项目名称:reduction,代码行数:27,代码来源:deadtime_fit.py
示例6: main
def main(self):
global weights, densities, weighted_densities
plt.figure()
cluster = clusters.SingleStation()
self.station = cluster.stations[0]
R = np.linspace(0, 100, 100)
densities = []
weights = []
for E in np.linspace(1e13, 1e17, 10000):
relative_flux = E ** -2.7
Ne = 10 ** (np.log10(E) - 15 + 4.8)
self.ldf = KascadeLdf(Ne)
min_dens = self.calculate_minimum_density_for_station_at_R(R)
weights.append(relative_flux)
densities.append(min_dens)
weights = np.array(weights)
densities = np.array(densities).T
weighted_densities = (np.sum(weights * densities, axis=1) /
np.sum(weights))
plt.plot(R, weighted_densities)
plt.yscale('log')
plt.ylabel("Min. density [m^{-2}]")
plt.xlabel("Core distance [m]")
plt.axvline(5.77)
plt.show()
开发者ID:HiSPARC,项目名称:sapphire,代码行数:29,代码来源:toy_energy_densities.py
示例7: Validation
def Validation():
numSamples = 1000000
theta = np.random.rand(numSamples)*np.pi
ECo60 = np.array([1.117,1.332])
Ef0,Ee0 = Compton(ECo60[0],theta)
Ef1,Ee1 = Compton(ECo60[1],theta)
dSdE0 = diffXSElectrons(ECo60[0],theta)
dSdE1 = diffXSElectrons(ECo60[1],theta)
# Sampling Values
values = list()
piMax = np.max([dSdE0,dSdE1])
while (len(values) < numSamples):
values.append(SampleRejection(piMax,ComptonScattering))
# Binning the data
bins = np.logspace(-3,0.2,100)
counts = np.histogram(values,bins)
counts = counts[0]/float(len(values))
binCenters = 0.5*(bins[1:]+bins[:-1])
# Plotting
pylab.figure()
pylab.plot(binCenters,counts,ls='steps')
#pylab.bar(binCenters,counts,align='center')
pylab.grid(True)
pylab.xlim((1E-3,1.4))
pylab.xlabel('Electron Energy (MeV)')
pylab.ylabel('Frequency per Photon')
pylab.yscale('log')
pylab.xscale('log')
pylab.savefig('ValComptonScatteringXS.png')
开发者ID:architkumar02,项目名称:murphs-code-repository,代码行数:32,代码来源:ComptonScattering.py
示例8: con
def con(text, stopwords):
alfa = []
content = [w for w in text if w.lower() not in stopwords and w.isalpha()]
fdist = FreqDist(content)
keys = fdist.keys()
vals = fdist.values()
maxiFreq = vals[0]
for i in range(1, maxiFreq + 1):
k = len([w for w in keys if fdist[w] == i])
alfa.append(k)
ys = range(1, maxiFreq + 1)
xs = alfa
pylab.xlabel("Anzahl der Woerter")
pylab.ylabel("Haeufigkeit")
pylab.plot(xs, ys)
pylab.show()
pylab.xlabel("Anzahl der Woerter log scale")
pylab.ylabel("Haeufigkeit log scale")
pylab.plot(xs, ys)
pylab.xscale('log')
pylab.yscale('log')
pylab.show()
return alfa
开发者ID:abtin63,项目名称:Web-Mining,代码行数:25,代码来源:aufgabe3_2.py
示例9: save_plot
def save_plot(l, xlabel=None, title=None, filename=None, xticks_labels=None, legend_loc='upper left', bottom_adjust=None, yscale='linear', ymin=0.0, ymax_factor=1.1):
params = {
'backend': 'ps',
#'text.usetex': True,'
'text.latex.unicode': True,
}
pylab.rcParams.update(params)
pylab.figure(1, figsize=(6,4))
pylab.grid(True)
pylab.xlabel(xlabel)
pylab.ylabel(u"čas [s]")
pylab.title(title)
pylab.xlim(0, max(l[0][0][0]) * 1.1)
if xticks_labels is not None:
pylab.xticks(l[0][0][0], xticks_labels, rotation=25, size='small', horizontalalignment='right')
ymax = 0.0
for i in l:
pylab.plot(*i[0], **i[1])
ymax = max(ymax,max(i[0][1]))
pylab.ylim(ymin, ymax * ymax_factor)
if bottom_adjust is not None:
pylab.subplots_adjust(bottom=bottom_adjust)
pylab.yscale(yscale)
pylab.legend(loc=legend_loc)
pylab.savefig(filename, format='eps')
pylab.clf()
开发者ID:Artimi,项目名称:neng-bp,代码行数:26,代码来源:performace_tests.py
示例10: plot_stats
def plot_stats(sbstats):
subbands = map(subband_from_stats, sbstats)
flagged = [max(sb['real']['flagged%'],sb['imag']['flagged%']) for sb in sbstats]
astd = [sb['real']['all-std'] for sb in sbstats]
gstd = [sb['real']['good-std'] for sb in sbstats]
clf()
subplot(311)
title('Flagged')
plot(subbands, flagged)
xlabel('Subband number')
subplot(312)
title(r'$\sigma$ all')
plot(subbands, astd)
yscale('log')
xlabel('Subband number')
subplot(313)
title(r'$\sigma$ good')
plot(subbands, gstd)
yscale('log')
xlabel('Subband number')
pass
开发者ID:SterVeen,项目名称:pyautoplot,代码行数:25,代码来源:main.py
示例11: makeComp
def makeComp(save=0):
data = Repeatability.getRepeatsData()
dc = data['dc_min']
dv = data['dv']
P.figure()
P.plot( dc, dv, 'k.', alpha=0.4)
P.ylim(0.1, 1e6)
P.xlim(1e-6, 1)
P.xscale('log')
P.yscale('log')
ylim = P.ylim()
P.plot( [1e-2, 1e-2], ylim, 'b--', lw=2)
P.plot( [5e-3, 5e-3], ylim, 'r--', lw=2)
P.plot( [1e-6, 1], [1000, 1000], 'm--', lw=2)
P.xlabel(r'$\Delta \chi^2/dof$')
P.ylabel(r'$\Delta v$ (km/s)')
P.tight_layout()
if save:
P.savefig(Repeatability.directory+'/plots/Repeat_all_rchi2_vel.pdf',\
bbox_inches='tight')
ngals = len(dv)*1.
print 'Total galaxies in plot', ngals
print ' dchi2 < 0.01', N.sum( dc< 0.01), N.sum( dc< 0.01)/ngals
print ' dchi2 < 0.005', N.sum( dc< 0.005), N.sum( dc< 0.005)/ngals
print ' dv > 1000 km/s', N.sum( dv > 1000.), N.sum( dv > 1000.)/ngals
return data
开发者ID:julienguy,项目名称:redfit,代码行数:31,代码来源:RepeatsPlot.py
示例12: plot_tmp_imp
def plot_tmp_imp( name_plot ):
# distance between axes and ticks
pl.rcParams['xtick.major.pad']='8'
pl.rcParams['ytick.major.pad']='8'
# set latex font
pl.rc('text', usetex=True)
pl.rc('font', **{'family': 'serif', 'serif': ['Computer Modern'], 'size': 20})
# plotting
x_plf = pow(10,pl.linspace(-6,0,1000))
pl.clf()
p_pl, = pl.plot(x_plf,ff_pl(x_plf,par_pl[0],par_pl[1]), ls='--', color='Red')
p_lg, = pl.plot(x_plf,ff_lg(x_plf,par_lg[0],par_lg[1]), ls='-', color='RoyalBlue')
p_points, = pl.plot(df_imp_1d.pi,df_imp_1d.imp,'.', color='Black',ms=10)
pl.xscale('log')
pl.yscale('log')
pl.xlabel('$\phi$')
pl.ylabel('$\mathcal{I}_{tmp}(\Omega=\{ \phi \})$')
pl.grid()
pl.axis([0.00001,1,0.0001,0.1])
leg_1 = '$\hat{Y} = $' + str("%.4f" % round(par_pl[0],4)) + '$\pm$' + str("%.4f" % round(vv_pl[0][0],4)) + ' $\hat{\delta} = $' + str("%.4f" % round(par_pl[1],4)) + '$\pm$' + str("%.4f" % round(vv_pl[1][1],4)) + ' $E_{RMS} = $' + str("%.4f" % round(pl.sqrt(chi_pl/len(df_imp_1d.imp)),4))
leg_2 = '$\hat{a} = $' + str("%.3f" % round(par_lg[0],3)) + '$\pm$' + str("%.3f" % round(vv_lg[0][0],3)) + ' $\hat{b} = $' + str("%.0f" % round(par_lg[1],3)) + '$\pm$' + str("%.0f" % round(vv_lg[1][1],3)) + ' $E_{RMS} = $' + str("%.4f" % round(pl.sqrt(chi_lg/len(df_imp_1d.imp)),4))
l1 = pl.legend([p_pl,p_lg], ['$f(\phi) = Y\phi^{\delta}$', '$g(\phi)= a \log_{10}(1+b\phi)$'], loc=2, prop={'size':15})
l2 = pl.legend([p_pl,p_lg], [leg_1 ,leg_2 ], loc=4, prop={'size':15})
pl.gca().add_artist(l1)
pl.subplots_adjust(bottom=0.15)
pl.subplots_adjust(left=0.17)
pl.savefig("../plot/" + name_plot + ".pdf")
开发者ID:patricktersh,项目名称:bmll,代码行数:32,代码来源:imp_tmp.py
示例13: 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
示例14: plot
def plot(self):
f = pylab.figure(figsize=(8,4))
co = [] #colors container
for label, (pVal, logratio) in self.data.get(["pValue", "log2Ratio"]).iterrows():
if pVal < self.pCut:
if logratio > 0:
co.append(Colors().redColor)
elif logratio < 0:
co.append(Colors().greenColor)
else:
raise Exception
else:
co.append(Colors().blueColor)
#print "Probability this is from a normal distribution: %.3e" %stats.normaltest(self.log2Ratio)[1]
#ax = f.add_subplot(121)
#pylab.axvline(self.meanLog2Ratio, color=Colors().redColor)
#pylab.axvspan(self.meanLog2Ratio-(2*self.stdLog2Ratio),
# self.meanLog2Ratio+(2*self.stdLog2Ratio), color=Colors().blueColor, alpha=0.2)
#his = pylab.hist(self.log2Ratio, bins=50, color=Colors().blueColor)
#pylab.xlabel("log2 Ratio %s/%s" %(self.sampleNames[1], self.sampleNames[0]))
#pylab.ylabel("Frequency")
ax = f.add_subplot(111, aspect='equal')
pylab.scatter(self.genes1, self.genes2, c=co, alpha=0.5)
pylab.ylabel("%s RPKM" %self.sampleNames[1])
pylab.xlabel("%s RPKM" %self.sampleNames[0])
pylab.yscale('log')
pylab.xscale('log')
pylab.tight_layout()
开发者ID:olgabot,项目名称:gscripts,代码行数:30,代码来源:rpkmZ.py
示例15: run_analysis
def run_analysis(filename,mode,method):
click.echo('Reading file : %s'%filename)
data = IOfile.parsing_input_file(filename)
click.echo('Creating class...')
theclass = TFC(data)
click.echo('Calculating transfer function using %s method'%method)
if method=='tf_kramer286_sh':
theclass.tf_kramer286_sh()
elif method=='tf_knopoff_sh':
theclass.tf_knopoff_sh()
elif method=='tf_knopoff_sh_adv':
theclass.tf_knopoff_sh_adv()
plt.plot(theclass.freq,np.abs(theclass.tf[0]),label=method)
plt.xlabel('frequency (Hz)')
plt.ylabel('Amplification')
plt.yscale('log')
plt.xscale('log')
plt.grid(True,which='both')
plt.legend(loc='best',fancybox=True,framealpha=0.5)
#plt.axis('tight')
plt.autoscale(True,axis='x',tight=True)
plt.tight_layout()
plt.savefig('test.png', format='png')
click.echo(click.style('Calculation has been finished!',fg='green'))
开发者ID:blueray45,项目名称:GSRT,代码行数:25,代码来源:GSRT.py
示例16: test_fit_bb
def test_fit_bb(self):
def func(nu, T):
return np.pi * rf.planck(nu, T, inp="Hz", out="freq")
self.sp.cut_flux(max(self.sp.Flux) * 1e-5)
freq = self.sp.Freq
flux = self.sp.Flux
Tinit = 1.e4
popt, pcov = curve_fit(func, freq, flux, p0=Tinit)
Tbest = popt
# bestT, pcov = curve_fit(rf.fit_planck(nu, inp='Hz'), nu, flux, p0=Tinit, sigma=sigma)
sigmaT = np.sqrt(np.diag(pcov))
print 'True model values'
print ' Tbb = %.2f K' % self.sp.T
print 'Parameters of best-fitting model:'
print ' T = %.2f +/- %.2f K' % (Tbest, sigmaT)
# Tcol = self.sp.temp_color
ybest = np.pi * rf.planck(freq, Tbest, inp="Hz", out="freq")
# plot the solution
plt.plot(freq, flux, 'b*', label='Spectral T: %f' % self.sp.T)
plt.plot(freq, ybest, 'r-', label='Best Tcol: %f' % Tbest)
plt.xscale('log')
plt.yscale('log')
plt.legend(loc=3)
plt.show()
self.assertAlmostEqual(Tbest, self.sp.T,
msg="For planck Tcolor [%f] should be equal sp.T [%f]." % (Tbest, self.sp.T),
delta=Tbest*0.01)
开发者ID:baklanovp,项目名称:pystella,代码行数:34,代码来源:test_bb_fitting.py
示例17: demo
def demo():
import pylab
# The module normalize is not part of the osrefl code base.
from reflectometry.reduction import normalize
from .examples import ng7 as dataset
spec = dataset.spec()[0]
water = WaterIntensity(D2O=20,probe=spec.probe)
spec.apply(normalize())
theory = water.model(spec.Qz,spec.detector.wavelength)
pylab.subplot(211)
pylab.title('Data normalized to water scattering (%g%% D2O)'%water.D2O)
pylab.xlabel('Qz (inv Ang)')
pylab.ylabel('Reflectivity')
pylab.semilogy(spec.Qz,theory,'-',label='expected')
scale = theory[0]/spec.R[0]
pylab.errorbar(spec.Qz,scale*spec.R,scale*spec.dR,fmt='.',label='measured')
spec.apply(water)
pylab.subplot(212)
#pylab.title('Intensity correction factor')
pylab.xlabel('Slit 1 opening (mm)')
pylab.ylabel('Incident intensity')
pylab.yscale('log')
pylab.errorbar(spec.slit1.x,spec.R,spec.dR,fmt='.',label='correction')
pylab.show()
开发者ID:reflectometry,项目名称:osrefl,代码行数:29,代码来源:ratiocor.py
示例18: quartile_plot
def quartile_plot(
fits,
group_index_start, group_index_end,
model_param_index,
ylim=None,
log=True,
xlabel=None,
ylabel=None,
labels=None):
model_param_values = [
fit_params(fits, group_index, model_param_index)
for group_index in xrange(
group_index_start, group_index_end)
]
fig = plt.figure(figsize=(len(model_param_values), 7))
if log is True:
plt.yscale('log')
if ylim is not None:
plt.ylim(ylim)
if xlabel is not None:
plt.xlabel(xlabel)
if ylabel is not None:
plt.ylabel(ylabel)
plt.boxplot(
model_param_values,
labels=labels,
showmeans=True)
plt.grid()
plt.show()
开发者ID:tomasra,项目名称:ga_sandbox,代码行数:29,代码来源:results.py
示例19: _set_axis_parameter
def _set_axis_parameter( self ):
# set axis to equal length
params = self.__params
ax_0 = self._get_axis()
# set axis aspect
pylab.xlim(params['xlim'])
pylab.ylim(params['ylim'])
x0,x1 = ax_0.get_xlim()
y0,y1 = ax_0.get_ylim()
if params['xlog'] and params['ylog']:
delta_x = float(np.log(x1)-np.log(x0))
delta_y = float(np.log(y1)-np.log(y0))
else:
delta_x = float(x1 - x0)
delta_y = float(y1 - y0)
ax_0.set_aspect(delta_x/delta_y)
# set tick size
ax_0.tick_params(axis='both', labelsize=params['ticksize'])
# set logarithmic scale
if params['xlog']:
pylab.xscale('log')
if params['grid']:
ax_0.xaxis.grid( True, which='both' )
if params['ylog']:
pylab.yscale('log')
if params['grid']:
ax_0.yaxis.grid( True, which='both' )
# grid below bars and boxes
ax_0.set_axisbelow(params['axisbelow'])
开发者ID:darp,项目名称:plot-tools,代码行数:29,代码来源:AbstractPlot.py
示例20: TestOverStep
def TestOverStep():
nDim = 10
numOfParticles = 20
maxIteration = 2000
minX = array([-100.0]*nDim)
maxX = array([100.0]*nDim)
maxV = 0.2*(maxX - minX)
minV = -1.0*maxV
numOfTrial = 20
intDim = 5
stopstep = 200
for i in xrange(4):
step = i*3
gBest = array([0.0]*maxIteration)
for i in xrange(numOfTrial):
p1 = AOPSO.PSOProblem(nDim, numOfParticles, maxIteration, minX, maxX, minV, maxV, AOPSO.Rastrigrin,intDim,step, stopstep)
p1.run()
gBest = gBest + p1.gBestArray[:maxIteration]
gBest = gBest / numOfTrial
pylab.plot(range(maxIteration), gBest,label='step='+str(step))
pylab.title('Rastrigrin function, intDim=5 ($G_{best}$ over 20 trials)')
pylab.xlabel('The $N^{th}$ Iteration')
pylab.ylabel('Average gBest over '+str(numOfTrial)+' runs')
pylab.grid(True)
pylab.yscale('log')
ylim = [-6, 1]
ystep = 1.0
# pylab.ylim(ylim[0], ylim[1])
# yticks = linspace(ylim[0], ylim[1], int((ylim[1]-ylim[0])/ystep+1))
# pylab.yticks(tuple(yticks), tuple(map(str,yticks)))
pylab.legend(loc='lower left')
pylab.show()
开发者ID:lonAlpha,项目名称:mi-pso,代码行数:32,代码来源:AOPSO_multipleRun.py
注:本文中的pylab.yscale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论