本文整理汇总了Python中biggles.FramedPlot.add方法的典型用法代码示例。如果您正苦于以下问题:Python FramedPlot.add方法的具体用法?Python FramedPlot.add怎么用?Python FramedPlot.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类biggles.FramedPlot
的用法示例。
在下文中一共展示了FramedPlot.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_masserr
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def plot_masserr(self, filename):
import pcolors
data=eu.io.read(filename)
nr200 = data.size
nb = data['B'][0].size
plt = FramedPlot()
colors = pcolors.rainbow(nr200, 'hex')
clist = []
for ri in xrange(nr200):
r200 = data['r200'][ri]
m200 = data['m200'][ri]
p = Points(data['B'][ri], (m200-data['m200meas'][ri])/m200,
type='filled circle', color=colors[ri])
crv = Curve(data['B'][ri], (m200-data['m200meas'][ri])/m200,
color=colors[ri])
crv.label = 'r200: %0.2f' % r200
clist.append(crv)
plt.add(p,crv)
key = PlotKey(0.1,0.4,clist)
plt.add(key)
plt.xlabel=r'$\Omega_m \sigma_8^2 D(z)^2 b(M,z)$'
plt.ylabel = r'$(M_{200}^{true}-M)/M_{200}^{true}$'
epsfile = filename.replace('.rec','.eps')
print 'writing eps:',epsfile
plt.write_eps(eu.ostools.expand_path(epsfile))
示例2: plot_nfwfits_byrun
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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: plot_radec
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def plot_radec(self, type):
"""
ra/dec plot of all points and the matched points
"""
import biggles
import converter
from biggles import FramedPlot,Points
print()
dir=self.plotdir()
if not os.path.exists(dir):
os.makedirs(dir)
psfile = self.plotfile(type)
orig = self.read_original(type)
mat = self.read_matched(type)
plt=FramedPlot()
symsize = 2
if type == 'sdss' or type == 'other':
symsize = 0.25
plt.add( Points(orig['ra'],orig['dec'],type='dot', size=symsize) )
plt.add( Points(mat['ra'],mat['dec'],type='dot',
color='red', size=symsize) )
plt.xlabel = 'RA'
plt.ylabel = 'DEC'
print("Writing eps file:", psfile)
plt.write_eps(psfile)
converter.convert(psfile, dpi=120, verbose=True)
示例4: plotprimedens
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def plotprimedens(n):
pd = primedens(n)
steps = range(len(pd))
from biggles import FramedPlot, Curve
g = FramedPlot()
g.add(Curve(steps,pd))
g.show()
return
示例5: doplot
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def doplot(self):
tab = Table(2, 1)
tab.title = self.title
xfit, yfit, gprior = self.get_prior_vals()
nrand = 100000
binsize = self.binsize
h = self.h
h1 = self.h1
h2 = self.h2
g1rand, g2rand = gprior.sample2d(nrand)
grand = gprior.sample1d(nrand)
hrand = histogram(grand, binsize=binsize, min=0.0, max=1.0, more=True)
h1rand = histogram(g1rand, binsize=binsize, min=-1.0, max=1.0, more=True)
fbinsize = xfit[1] - xfit[0]
hrand["hist"] = hrand["hist"] * float(yfit.sum()) / hrand["hist"].sum() * fbinsize / binsize
h1rand["hist"] = h1rand["hist"] * float(h1["hist"].sum()) / h1rand["hist"].sum()
pltboth = FramedPlot()
pltboth.xlabel = r"$g$"
hplt1 = Histogram(h1["hist"], x0=h1["low"][0], binsize=binsize, color="red")
hplt2 = Histogram(h2["hist"], x0=h2["low"][0], binsize=binsize, color="blue")
hpltrand = Histogram(hrand["hist"], x0=hrand["low"][0], binsize=binsize, color="magenta")
hplt1rand = Histogram(h1rand["hist"], x0=h1rand["low"][0], binsize=binsize, color="magenta")
hplt1.label = r"$g_1$"
hplt2.label = r"$g_2$"
hplt1rand.label = "rand"
hpltrand.label = "rand"
keyboth = PlotKey(0.9, 0.9, [hplt1, hplt2, hplt1rand], halign="right")
pltboth.add(hplt1, hplt2, hplt1rand, keyboth)
tab[0, 0] = pltboth
plt = FramedPlot()
plt.xlabel = r"$|g|$"
hplt = Histogram(h["hist"], x0=h["low"][0], binsize=binsize)
hplt.label = "|g|"
line = Curve(xfit, yfit, color="blue")
line.label = "model"
key = PlotKey(0.9, 0.9, [hplt, line, hpltrand], halign="right")
plt.add(line, hplt, hpltrand, key)
tab[1, 0] = plt
if self.show:
tab.show()
return tab
示例6: plot_pk
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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 add [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_T
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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()
示例9: plot_boss_geometry
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def plot_boss_geometry(color=None, colorwheel=None, plt=None, width=1, show=True,
region=None):
"""
Plot the boundaries in the boss_survey.par file
"""
import esutil as eu
import biggles
from biggles import FramedPlot, Curve
bg = read_boss_geometry()
if plt is None:
plt = FramedPlot()
plt.xlabel=r'$\lambda$'
plt.ylabel=r'$\eta$'
if color is not None:
colors = [color]*len(bg)
elif colorwheel is not None:
colors = colorwheel
else:
colors = ['red','blue','green','magenta','navyblue','seagreen',
'firebrick','cadetblue','green4']
for i in xrange(len(bg)):
b = bg[i]
color = colors[i % len(colors)]
c = eu.plotting.bbox( b['clambdaMin'], b['clambdaMax'], b['cetaMin'], b['cetaMax'],
color=color, width=width)
plt.add(c)
if region == 'ngc':
plt.yrange = [-40.,50.]
plt.xrange = [-80.,80.]
elif region == 'sgc':
plt.yrange = [105.,165.]
plt.xrange = [-60.,60.]
else:
plt.yrange = [-40.,165.]
plt.xrange = [-80.,80.]
plt.aspect_ratio = (plt.yrange[1]-plt.yrange[0])/(plt.xrange[1]-plt.xrange[0])
if show:
plt.show()
return plt
示例10: plot_xi
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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: doplot
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def doplot(self, fitres, h, minmag, maxmag):
tab=biggles.Table(2,1)
plt=FramedPlot()
plt.title='%s %.2f %.2f ' % (self.objtype, minmag, maxmag)
plt.xlabel=r'$\sigma$'
sprior=fitres.get_model()
nrand=100000
binsize=self.binsize
hplt=Histogram(h['hist'], x0=h['low'][0], binsize=binsize)
hplt.label='data'
srand=sprior.sample(nrand)
hrand=histogram(srand, binsize=binsize, min=h['low'][0], max=h['high'][-1], more=True)
hrand['hist'] = hrand['hist']*float(h['hist'].sum())/nrand
hpltrand=Histogram(hrand['hist'], x0=hrand['low'][0], binsize=binsize,
color='blue')
hpltrand.label='rand'
key=PlotKey(0.9,0.9,[hplt,hpltrand],halign='right')
plt.add(hplt, hpltrand, key)
tplt=fitres.plot_trials(show=False,fontsize_min=0.88888888)
tab[0,0] = plt
tab[1,0] = tplt
if self.show:
tab.show()
d=files.get_prior_dir()
d=os.path.join(d, 'plots')
epsfile='pofs-%.2f-%.2f-%s.eps' % (minmag,maxmag,self.objtype)
epsfile=os.path.join(d,epsfile)
eu.ostools.makedirs_fromfile(epsfile)
print epsfile
tab.write_eps(epsfile)
os.system('converter -d 100 %s' % epsfile)
return tab
示例12: compare_all_other
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def compare_all_other(self, type, show=True):
fdict=self.all_other_fdict(type)
# this is the original file. It has the redshifts
orig = zphot.weighting.read_training(fdict['origfile'])
# this is the outputs
num = zphot.weighting.read_num(fdict['numfile1'])
# this is the weights file
weights = zphot.weighting.read_training(fdict['wfile2'])
# recoverable set
w_recoverable = where1(num['num'] > 0)
# this is actually the indexes back into the "orig" file
w_keep = num['photoid'][w_recoverable]
# get the z values for these validation objects
zrec = orig['z'][w_keep]
binsize=0.0314
valid_dict = histogram(zrec, min=0, max=1.1, binsize=binsize, more=True)
plt=FramedPlot()
vhist = valid_dict['hist']/(float(valid_dict['hist'].sum()))
pvhist=biggles.Histogram(vhist, x0=valid_dict['low'][0], binsize=binsize)
pvhist.label = 'truth'
weights_dict = histogram(weights['z'], min=0, max=1.1, binsize=binsize,
weights=weights['weight'], more=True)
whist = weights_dict['whist']/weights_dict['whist'].sum()
pwhist=biggles.Histogram(whist, x0=weights_dict['low'][0],
binsize=binsize, color='red')
pwhist.label = 'weighted train'
key = PlotKey(0.6,0.6,[pvhist,pwhist])
plt.add(pvhist,pwhist,key)
plt.add( biggles.PlotLabel(.8, .9, type) )
plt.write_eps(fdict['zhistfile'])
converter.convert(fdict['zhistfile'],dpi=90,verbose=True)
if show:
plt.show()
示例13: test_rainbow
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [as 别名]
def test_rainbow():
import numpy
from biggles import FramedPlot, Points, Curve
num = 20
plt = FramedPlot()
x = numpy.linspace(0.0, 1.0, num)
y = x**2
colors = rainbow(num, 'hex')
for i in xrange(num):
p = Points([x[i]], [y[i]], type='filled circle',
color=colors[i])
c = Curve([x[i]],[y[i]], color=colors[i])
plt.add(p,c)
plt.show()
示例14: test_interp_hybrid
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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()
示例15: plot_sub_pixel
# 需要导入模块: from biggles import FramedPlot [as 别名]
# 或者: from biggles.FramedPlot import add [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)