本文整理汇总了Python中biggles.FramedPlot.xlog方法的典型用法代码示例。如果您正苦于以下问题:Python FramedPlot.xlog方法的具体用法?Python FramedPlot.xlog怎么用?Python FramedPlot.xlog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biggles.FramedPlot
的用法示例。
在下文中一共展示了FramedPlot.xlog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_T
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_T(self, k, T, Tc=None, Tb=None):
from biggles import FramedPlot, Curve, PlotKey
plt=FramedPlot()
c=Curve(k, T**2)
c.label = '$T^2$'
plt.add(c)
plist = [c]
if Tc is not None:
cc=Curve(k,Tc**2,color='blue')
cc.label = '$Tc^2$'
plt.add(cc)
plist.append(cc)
if Tb is not None:
tmp = where(Tb < 1.e-5, 1.e-5, Tb)
cb=Curve(k,tmp**2,color='red')
cb.label = '$Tb^2$'
plt.add(cb)
plist.append(cb)
plt.xlog=True
plt.ylog=True
plt.ylabel = '$T^2'
plt.xlabel = 'k'
plt.yrange = [1.e-8,1.0]
plt.aspect_ratio=1
if Tc is not None or Tb is not None:
key=PlotKey(0.1,0.9,plist)
plt.add(key)
plt.show()
示例2: plot_nfwfits_byrun
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_nfwfits_byrun(run, name, prompt=False):
conf = lensing.files.read_config(run)
d = lensing.sample_read(type='fit', sample=run, name=name)
omega_m = conf['omega_m']
rvals = numpy.linspace(d['r'].min(), d['r'].max(),1000)
for i in xrange(d.size):
plt = FramedPlot()
lensing.plotting.add_to_log_plot(plt,
d['r'][i],
d['dsig'][i],
d['dsigerr'][i])
z = d['z_mean'][i]
n = lensing.nfw.NFW(omega_m, z)
yfit = n.dsig(rvals, d['r200_fit'][i],d['c_fit'][i])
plt.add(Curve(rvals,yfit,color='blue'))
plt.xlog=True
plt.ylog=True
plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
plt.ylabel = r'$\Delta\Sigma ~ [M_{sun} pc^{-2}]$'
if prompt:
plt.show()
raw_input('hit a key: ')
else:
epsfile='/home/esheldon/tmp/plots/desmocks-nfwfit-%02i.eps' % i
print 'Writing epsfile:',epsfile
plt.write_eps(epsfile)
示例3: test_fit_nfw_dsig
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def test_fit_nfw_dsig(rmin=0.01):
from biggles import FramedPlot,Points,SymmetricErrorBarsY,Curve
omega_m=0.25
z=0.25
n = lensing.nfw.NFW(omega_m, z)
r200 = 1.0
c = 5.0
rmax = 5.0
log_rmin = log10(rmin)
log_rmax = log10(rmax)
npts = 25
logr = numpy.linspace(log_rmin,log_rmax,npts)
r = 10.0**logr
ds = n.dsig(r, r200, c)
# 10% errors
dserr = 0.1*ds
ds += dserr*numpy.random.standard_normal(ds.size)
guess = numpy.array([r200,c],dtype='f8')
# add 10% error to the guess
guess += 0.1*guess*numpy.random.standard_normal(guess.size)
res = fit_nfw_dsig(omega_m, z, r, ds, dserr, guess)
r200_fit = res['r200']
r200_err = res['r200_err']
c_fit = res['c']
c_err = res['c_err']
print 'Truth:'
print ' r200: %f' % r200
print ' c: %f' % c
print 'r200_fit: %f +/- %f' % (r200_fit,r200_err)
print ' c_fit: %f +/- %f' % (c_fit,c_err)
print 'Cov:'
print res['cov']
logr = numpy.linspace(log_rmin,log_rmax,1000)
rlots = 10.0**logr
yfit = n.dsig(rlots,r200_fit,c_fit)
plt=FramedPlot()
plt.add(Points(r,ds,type='filled circle'))
plt.add(SymmetricErrorBarsY(r,ds,dserr))
plt.add(Curve(rlots,yfit,color='blue'))
plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
plt.ylabel = r'$\Delta\Sigma ~ [M_{sun} pc^{-2}]$'
plt.xrange = [0.5*rmin, 1.5*rmax]
plt.yrange = [0.5*(ds-dserr).min(), 1.5*(ds+dserr).max()]
plt.xlog=True
plt.ylog=True
plt.show()
示例4: test_interp_hybrid
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def test_interp_hybrid():
"""
Send y0,y1 with one or both less than zero to test the
hybrid offset scheme
"""
slope = -2.0
#xvals = 0.1+linspace(0.0,8.0,9)
xvals = 10.0**linspace(0.0,1.0,10)
yvals = xvals**slope
#yerr = 0.5*yvals
#yerr = sqrt(yvals)
yerr = yvals.copy()
yerr[:] = 0.05
#xfine = 0.1+linspace(0.0,8.0,1000)
xfine = 10.0**linspace(0.0,1.0,1000)
yfine = xfine**slope
#yerr = yvals.copy()
#yerr[:] = 2
plt=FramedPlot()
plt.xrange = [0.5*xvals.min(), 1.5*xvals.max()]
plt.xlog=True
#plt.ylog=True
plt.add(Points(xvals,yvals,type='filled circle',size=1))
plt.add(Curve(xfine,yfine,color='blue'))
#w=where1( (yvals-yerr) > 1.e-5 )
#plt.add(SymmetricErrorBarsY(xvals[w],yvals[w],yerr[w]))
plt.add(SymmetricErrorBarsY(xvals,yvals,yerr))
# make points in between consecutive xvals,yvals so we
# can use hybrid 2-point function
xi = numpy.zeros(xvals.size-1,dtype='f8')
yi = numpy.zeros(xi.size,dtype='f8')
for i in xrange(xi.size):
logx = (log10(xvals[i+1])+log10(xvals[i]))/2.0
xi[i] = 10.0**logx
yi[i],amp,slope,off = interp_hybrid(xvals[i], xvals[i+1],
yvals[i], yvals[i+1],
yerr[i], yerr[i+1],
xi[i],more=True)
print 'amp:',amp
print 'slope:',slope
print 'off:',off
print xvals
print xi
print yi
plt.add( Points(xi, yi, type='filled circle', size=1, color='red'))
plt.show()
示例5: make_plot
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def make_plot(self):
bindata=self.bindata
bin_field=self.bin_field
plt=FramedPlot()
plt.uniform_limits=1
plt.xlog=True
#plt.xrange=[0.5*bindata[bin_field].min(), 1.5*bindata[bin_field].max()]
plt.xrange=self.s2n_range
plt.xlabel=bin_field
plt.ylabel = r'$\gamma$'
if self.yrange is not None:
plt.yrange=self.yrange
xdata=bindata[bin_field]
xerr=bindata[bin_field+'_err']
if self.shnum in sh1exp:
g1exp=zeros(xdata.size)+sh1exp[self.shnum]
g2exp=zeros(xdata.size)+sh2exp[self.shnum]
g1exp_plt=Curve(xdata, g1exp)
g2exp_plt=Curve(xdata, g2exp)
plt.add(g1exp_plt)
plt.add(g2exp_plt)
xerrpts1 = SymmetricErrorBarsX(xdata, bindata['g1'], xerr)
xerrpts2 = SymmetricErrorBarsX(xdata, bindata['g2'], xerr)
type='filled circle'
g1color='blue'
g2color='red'
g1pts = Points(xdata, bindata['g1'], type=type, color=g1color)
g1errpts = SymmetricErrorBarsY(xdata, bindata['g1'], bindata['g1_err'], color=g1color)
g2pts = Points(xdata, bindata['g2'], type=type, color=g2color)
g2errpts = SymmetricErrorBarsY(xdata, bindata['g2'], bindata['g2_err'], color=g2color)
g1pts.label=r'$\gamma_1$'
g2pts.label=r'$\gamma_2$'
key=biggles.PlotKey(0.9,0.5,[g1pts,g2pts],halign='right')
plt.add( xerrpts1, g1pts, g1errpts )
plt.add( xerrpts2, g2pts, g2errpts )
plt.add(key)
labels=self.get_labels()
plt.add(*labels)
plt.aspect_ratio=1
self.plt=plt
示例6: plot_pk
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_pk(self,k,pk):
from biggles import FramedPlot, Curve
plt=FramedPlot()
plt.add(Curve(k,pk))
plt.xlog=True
plt.ylog=True
plt.xlabel = r'$k [h/Mpc]$'
plt.ylabel = r'$P_{lin}(k)$'
plt.aspect_ratio = 1
plt.show()
示例7: plot_m
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_m(self, r200, c):
from biggles import FramedPlot, Curve
n=1000
r = numpy.linspace(0.01, 20.0,n)
m = self.m(r, r200, c)
plt=FramedPlot()
plt.add( Curve(r,m) )
plt.xlog=True
plt.ylog=True
plt.show()
示例8: plot_sub_pixel
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_sub_pixel(ellip,theta, show=False):
import biggles
from biggles import PlotLabel,FramedPlot,Table,Curve,PlotKey,Points
from pcolors import rainbow
f=subpixel_file(ellip,theta,'fits')
data = eu.io.read(f)
colors = rainbow(data.size,'hex')
pltSigma = FramedPlot()
pltSigma.ylog=1
pltSigma.xlog=1
curves=[]
for j in xrange(data.size):
sigest2 = (data['Irr'][j,:] + data['Icc'][j,:])/2
pdiff = sigest2/data['sigma'][j]**2 -1
nsub=numpy.array(data['nsub'][j,:])
#pc = biggles.Curve(nsub, pdiff, color=colors[j])
pp = Points(data['nsub'][j,:], pdiff, type='filled circle',color=colors[j])
pp.label = r'$\sigma: %0.2f$' % data['sigma'][j]
curves.append(pp)
pltSigma.add(pp)
#pltSigma.add(pc)
#pltSigma.yrange=[0.8,1.8]
#pltSigma.add(pp)
c5 = Curve(linspace(1,8, 20), .005+zeros(20))
pltSigma.add(c5)
key=PlotKey(0.95,0.95,curves,halign='right',fontsize=1.7)
key.key_vsep=1
pltSigma.add(key)
pltSigma.xlabel='N_{sub}'
pltSigma.ylabel=r'$\sigma_{est}^2 /\sigma_{True}^2 - 1$'
lab=PlotLabel(0.05,0.07,r'$\epsilon: %0.2f \theta: %0.2f$' % (ellip,theta),halign='left')
pltSigma.add(lab)
pltSigma.yrange = [1.e-5,0.1]
pltSigma.xrange = [0.8,20]
if show:
pltSigma.show()
epsfile=subpixel_file(ellip,theta,'eps')
print("Writing eps file:",epsfile)
pltSigma.write_eps(epsfile)
示例9: plot_dsig_one
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_dsig_one(r, dsig, dsigerr, **kw):
"""
plot delta sigma
useful if adding to an existing plot
parameters
----------
r: array
radius
dsig: array
delta sigma
dsigerr: array
error on delta sigma
"""
from biggles import FramedPlot
nbin=1
_set_biggles_defs(nbin)
visible=kw.get('visible',True)
xlog=kw.get('xlog',True)
ylog=kw.get('ylog',True)
aspect_ratio=kw.get('aspect_ratio',1)
is_ortho=kw.get('is_ortho',False)
plt=kw.get('plt',None)
if plt is None:
plt=FramedPlot()
plt.aspect_ratio=aspect_ratio
plt.xlog=xlog
plt.ylog=ylog
plt.xlabel = LABELS['rproj']
if is_ortho:
plt.ylabel = LABELS['osig']
else:
plt.ylabel = LABELS['dsig']
xrng, yrng = _add_dsig_to_plot(plt, r, dsig, dsigerr, **kw)
plt.xrange=xrng
plt.yrange=yrng
if visible:
plt.show()
return plt
示例10: plot_xi
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_xi(self, r, xi):
from biggles import FramedPlot, Curve
minval = 1.e-4
xi = where(xi < minval, minval, xi)
plt=FramedPlot()
plt.add(Curve(r,xi))
plt.xlog=True
plt.ylog=True
plt.xlabel = r'$r [Mpc/h]$'
plt.ylabel = r'$\xi_{lin}(r)$'
plt.aspect_ratio=1
plt.show()
示例11: make_frac_plot
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def make_frac_plot(self):
if self.shnum not in sh1exp:
raise ValueError("you must know the expected value")
if sh1exp[self.shnum] != 0:
gfield='g1'
gtrue=sh1exp[self.shnum]
elif sh2exp[self.shnum] != 0:
gfield='g2'
gtrue=sh2exp[self.shnum]
else:
raise ValueError("all expected are listed as zero")
bindata=self.bindata
bin_field=self.bin_field
plt=FramedPlot()
plt.title=self.get_title()
plt.xlog=True
plt.xrange=[0.5*bindata[bin_field].min(), 1.5*bindata[bin_field].max()]
plt.xlabel=bin_field
ylabel=r'$\Delta \gamma/\gamma$'
plt.ylabel = ylabel
xdata=bindata[bin_field]
zero=zeros(xdata.size)
zero_plt=Curve(xdata, zero)
plt.add(zero_plt)
xfill=[xdata.min(), xdata.max()]
plt.add( biggles.FillBetween(xfill, [0.004,0.004],
xfill, [-0.004,-0.004],
color='grey80'))
gfrac = bindata[gfield]/gtrue-1
gfrac_err = bindata[gfield+'_err']/gtrue
type='filled circle'
color='blue'
gpts = Points(xdata, gfrac, type=type, color=color)
gerrpts = SymmetricErrorBarsY(xdata, gfrac, gfrac_err,color=color)
plt.add( gpts, gerrpts )
self.plt=plt
示例12: test_xi_converge_nplk
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def test_xi_converge_nplk(epsfile=None):
"""
Test how xi converges with the number of k points per log10(k)
Note we should test other convergence factors too!
"""
tab=Table(2,1)
pltbig = FramedPlot()
pltzoom = FramedPlot()
pltbig.xlabel='r'
pltbig.ylabel='xi(r)'
pltbig.xlog=True
pltbig.ylog=True
pltzoom.xlabel='r'
pltzoom.ylabel='xi(r)'
l=Linear()
r=10.0**linspace(0.0,2.3,1000)
nplk_vals = [20,60,100,140,160]
color_vals = ['blue','skyblue','green','orange','magenta','red']
plist=[]
lw=2.4
for nplk,color in zip(nplk_vals,color_vals):
print 'nplk:',nplk
xi = l.xi(r, nplk=nplk)
limxi = where(xi < 1.e-5, 1.e-5, xi)
climxi = Curve(r,limxi,color=color,linewidth=lw)
climxi.label = 'nplk: %i' % nplk
pltbig.add(climxi)
plist.append(climxi)
w=where1(r > 50.0)
cxi = Curve(r[w], xi[w], color=color, linewidth=lw)
pltzoom.add(cxi)
key = PlotKey(0.7,0.8, plist)
pltzoom.add(key)
tab[0,0] = pltbig
tab[1,0] = pltzoom
if epsfile is not None:
tab.write_eps(epsfile)
else:
tab.show()
示例13: plot_drho
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_drho(comb=None, r=None, drho=None, drhoerr=None,
color='black',type='filled circle',
nolabel=False, noshow=False, minval=1.e-5,
aspect_ratio=1):
"""
This one stands alone.
"""
if comb is not None:
r=comb['rdrho']
drho=comb['drho']
drhoerr=comb['drhoerr']
else:
if r is None or drho is None or drhoerr is None:
raise ValueError("Send a combined struct or r,drho,drhoerr")
plt=FramedPlot()
plt.aspect_ratio=aspect_ratio
plt.xlog=True
plt.ylog=True
if not nolabel:
plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
plt.ylabel = r'$\delta\rho ~ [M_{\odot} pc^{-3}]$'
od=add_to_log_plot(plt, r, drho, drhoerr,
color=color,
type=type,
minval=minval)
# for drho we need even broader yrange
plt.xrange = od['xrange']
yr=od['yrange']
plt.yrange = [0.5*yr[0], 3*yr[1]]
if not noshow:
plt.show()
od['plt'] = plt
return od
示例14: plot_mass
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_mass(comb=None, r=None, mass=None, masserr=None,
color='black',type='filled circle',
nolabel=False, noshow=False, minval=1.e11,
aspect_ratio=1):
if comb is not None:
r=comb['rmass']
mass=comb['mass']
masserr=comb['masserr']
else:
if r is None or mass is None or masserr is None:
raise ValueError("Send a combined struct or r,mass,masserr")
plt=FramedPlot()
plt.aspect_ratio=aspect_ratio
plt.xlog=True
plt.ylog=True
if not nolabel:
plt.xlabel = r'$r$ [$h^{-1}$ Mpc]'
plt.ylabel = r'$M(<r) ~ [h^{-1} M_{\odot}]$'
od=add_to_log_plot(plt, r, mass, masserr,
color=color,
type=type,
minval=minval)
plt.xrange = od['xrange']
plt.yrange = od['yrange']
if not noshow:
plt.show()
od['plt'] = plt
return od
示例15: plot_meanshear_vs_trueshear_bys2n
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import xlog [as 别名]
def plot_meanshear_vs_trueshear_bys2n(self, nperbin, nperbin_sub, show=False):
from biggles import FramedPlot, Curve, Points, Table, PlotKey
type = "vs_shear"
html_file = get_shear_compare_html_url(self["run"], self["mock_catalog"], type)
print "html_file:", html_file
data = self.get_data()
epsfile = get_shear_compare_plot_url(self["run"], self["mock_catalog"], type)
print >> stderr, "Will write summary plot:", epsfile
print >> stderr, "histogramming shear_s2n", nperbin
hdict = eu.stat.histogram(data["shear_s2n"], nperbin=nperbin, rev=True, more=True)
rev = hdict["rev"]
cdlist = []
pngfiles = []
for i in xrange(hdict["hist"].size):
if rev[i] != rev[i + 1]:
w = rev[rev[i] : rev[i + 1]]
label = r"$%0.3g < S/N < %0.3g$" % (hdict["low"][i], hdict["high"][i])
print >> stderr, label, "mean:", hdict["mean"][i], "num:", w.size
cd, png = self.plot_meanshear_vs_trueshear(nperbin_sub, indices=w, label=label, num=i, show=show)
cdlist.append(cd)
pngfiles.append(png)
slopes1 = [cd["coeff1"][0] for cd in cdlist]
offsets1 = [cd["coeff1"][1] for cd in cdlist]
slopes2 = [cd["coeff2"][0] for cd in cdlist]
offsets2 = [cd["coeff2"][1] for cd in cdlist]
tab = Table(2, 1)
plt_slope = FramedPlot()
cslope1 = Curve(hdict["mean"], slopes1, color="red")
cslope2 = Curve(hdict["mean"], slopes2, color="blue")
pslope1 = Points(hdict["mean"], slopes1, color="red", type="filled circle")
pslope2 = Points(hdict["mean"], slopes2, color="blue", type="filled circle")
cslope1.label = r"$\gamma_1$"
cslope2.label = r"$\gamma_2$"
key = PlotKey(0.1, 0.2, [cslope1, cslope2], halign="left")
plt_slope.add(cslope1, cslope2, pslope1, pslope2, key)
plt_slope.xlabel = "Shear S/N"
plt_slope.ylabel = "Slope"
plt_slope.xlog = True
plt_slope.xrange = eu.plotting.get_log_plot_range(hdict["mean"])
plt_offset = FramedPlot()
coffset1 = Curve(hdict["mean"], offsets1, color="red")
coffset2 = Curve(hdict["mean"], offsets2, color="blue")
poffset1 = Points(hdict["mean"], offsets1, color="red", type="filled circle")
poffset2 = Points(hdict["mean"], offsets2, color="blue", type="filled circle")
plt_offset.add(coffset1, coffset2, poffset1, poffset2)
plt_offset.xlabel = "Shear S/N"
plt_offset.ylabel = "Offset"
plt_offset.xlog = True
plt_offset.xrange = eu.plotting.get_log_plot_range(hdict["mean"])
tab[0, 0] = plt_slope
tab[1, 0] = plt_offset
if show:
tab.show()
print >> stderr, "Writing summary plot:", epsfile
tab.write_eps(epsfile)
converter.convert(epsfile, dpi=90, verbose=True)
png = epsfile.replace(".eps", ".png")
pngfiles = [png] + pngfiles
self.write_html(pngfiles, html_file)