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