本文整理汇总了Python中matplotlib.pyplot.loglog函数的典型用法代码示例。如果您正苦于以下问题:Python loglog函数的具体用法?Python loglog怎么用?Python loglog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loglog函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: condtn_nm_plot
def condtn_nm_plot(G, w_start=-2, w_end=2, axlim=None, points=1000):
"""
Plot of the condition number, the maximum over the minimum singular value
Parameters
----------
G : numpy matrix
Plant model.
Returns
-------
Plot : matplotlib figure
Note
----
A condition number over 10 may indicate sensitivity to uncertainty and
control problems
With a small condition number, Gamma =1, the system is insensitive to
input uncertainty, irrespective of controller (p248).
"""
s, w, axlim = df.frequency_plot_setup(axlim, w_start, w_end, points)
def cndtn_nm(G):
return utils.sigmas(G)[0]/utils.sigmas(G)[-1]
freqresp = [G(si) for si in s]
plt.loglog(w, [cndtn_nm(Gfr) for Gfr in freqresp], label='$\gamma (G)$')
plt.axis(axlim)
plt.ylabel('$\gamma (G)$')
plt.xlabel('Frequency [rad/unit time]')
plt.axhline(10., color='red', ls=':', label='"Large" $\gamma (G) = 10$')
plt.legend()
开发者ID:Mvuyiso,项目名称:Skogestad-Python,代码行数:35,代码来源:utilsplot.py
示例2: __call__
def __call__(self,u,v,w,bx,by,bz):
q = 4
d = (self.sim.zmx, self.sim.ymx, self.sim.xmx)
vspec = spec(u,v,w,dims=d)
bspec = spec(bx,by,bz,dims=d)
plt.subplot(221)
plt.plot(vspec)
plt.semilogy()
plt.title('v-spec')
plt.axis("tight")
plt.ylim([1e-12,1e-2])
plt.subplot(222)
plt.plot(vspec)
plt.loglog()
plt.title('v-spec')
plt.axis("tight")
plt.ylim([1e-12,1e-2])
plt.subplot(223)
plt.plot(bspec)
plt.semilogy()
plt.title('b-spec')
plt.axis("tight")
plt.ylim([1e-12,1e-2])
plt.subplot(224)
plt.plot(bspec)
plt.loglog()
plt.title('b-spec')
plt.axis("tight")
plt.ylim([1e-12,1e-2])
开发者ID:BenByington,项目名称:PythonTools,代码行数:34,代码来源:calc_series.py
示例3: addPlot
def addPlot(title,lbl,ref=None):
inFile = file(title,'r')
entries=[]
for line in inFile:
if line=='\n' or line.startswith('Moments') or line.startswith('N,'):
continue
entries.append([])
vals=line.strip().split(',')
entries[-1].append(int(vals[0]))
entries[-1].append(float(vals[1]))
entries[-1].append(float(vals[2]))
entries=np.array(entries)
entries=entries[entries[:,0].argsort()]
if ref==None:
errs=np.zeros([len(entries)-1,3])
errs[:,0] = entries[:-1,0]
errs[:,1] = abs(entries[:-1,1]-entries[-1,1])/entries[-1,1]
errs[:,2] = abs(entries[:-1,2]-entries[-1,2])/entries[-1,2]
else:
errs=np.zeros([len(entries),3])
errs[:,0] = entries[:,0]
errs[:,1] = abs(entries[:,1]-ref[1])/ref[1]
errs[:,2] = abs(entries[:,2]-ref[2])/ref[2]
#for e in errs:
# print e
errs=errs[errs[:,0].argsort()]
# print '\n\n'
# for e in errs:
# print e
errs=zip(*errs)
plt.loglog(errs[0],errs[1],'-o',label=lbl)
开发者ID:taoyiliang,项目名称:unc-quant,代码行数:34,代码来源:plot1.py
示例4: makegood
def makegood(prereqs,func,r,size,grid,smallrexp,largerexp,plotting):
"""
prereqs - array containing model class instance as first element
func - function to be evaluated
r - independent variable array
size - size of generated independent variable array with format
[log10(max),log10(min),stepsize]
grid - choice of grid generator function
smallrexp - log slope at small r or large E
largerexp - log slope at large r or small E
plotting - if False, do not plot.
if not False, must be array with ['<xlabel>','<ylabel>']
Returns an interpolated object version of the function based
computed values.
"""
model = prereqs[0]
#generate independent array grid
rarray,rchange,rstart = grid([model],size[0],size[1],size[2])
#compute value of function for grid points
tab,problems = func(rarray,prereqs)
frac = float(len(problems))/float(len(tab))
#report the fraction of problem points to console and file
print 'fraction reporting a message: {0}'.format(frac)
model.statfile.write('\nmesg frac = {0}\n'.format(frac))
#check for problem points not caught in integration process
gcheck = goodcheck(tab)
#interpolate in log10 space
inter = interp1d(log10(rarray),log10(tab))
#generate array to further extremes using powerlaw behaviour
m = piecewise(r,inter,tab[0],tab[len(rarray)-1],rstart,rchange,smallrexp,largerexp)
#interpolate extended array in log10 space
inter2 = interp1d(log10(r),log10(m))
#save values used to interpolate to file (NOT in log10 space)
saver = column_stack((r,m))
funcname = str(func).split(' ')[1][4:]
pklwrite('{0}/{1}.pkl'.format(model.directory,funcname),saver)
#if plotting is possible and the array doesn't consist entirely of problems
#add plot to pdf and return interpolate functional form
if plotting != False and gcheck == True:
xaxis,yaxis = plotting
plt.figure()
plt.loglog(r[1:-1],m[1:-1],'c',linewidth = 5)
plt.loglog(rarray,tab,'.',color = 'DarkOrange')
plt.ylabel(r'{0}'.format(yaxis))
plt.xlabel('{0}'.format(xaxis))
plt.xlim(min(r[1:-1]),max(r[1:-1]))
plt.ylim(min(m[1:-1]),max(m[1:-1]))
plt.title(model.name)
model.pdfdump.savefig()
plt.close()
return inter2
#if plotting isn't possible but array doesn't consist entirely of problems
#return interpolated functional form
elif plotting == False and gcheck == True:
return inter2
#if computation failed, return 0
#this signals the rest of the program that computation failed here
elif gcheck == False:
return 0
开发者ID:NatalieP-J,项目名称:Summer2014,代码行数:60,代码来源:construction.py
示例5: plotBode2
def plotBode2(zpk, n=200, f_range=None, f_logspace=True):
"""
Bode plot of ZerosAndPoles object using matplotlib
"""
(f, y) = zpk.frequencyResponse(n=n, f_range=f_range, f_logspace=f_logspace)
y_A = numpy.abs(y)
y_phi = Misc.to_deg(Misc.continuousAngle(y))
plt.figure()
plt.subplot(211)
if f_logspace:
plt.loglog(f, y_A)
else:
plt.plot(f, y_A)
plt.grid(True, which="both")
plt.ylabel("Amplitude")
plt.subplot(212)
if f_logspace:
plt.semilogx(f, y_phi)
else:
plt.plot(f, y_A)
plt.grid(True, which="both")
plt.xlabel("Frequency [Hz]")
plt.ylabel("Phase [deg]")
plt.show()
开发者ID:yeus,项目名称:PySimulator,代码行数:28,代码来源:PlotMatplotlib.py
示例6: plot_shortest_path_spectrum
def plot_shortest_path_spectrum (graph, path, paths_data):
"""Plot distribution of shortest paths of the graph and save the figure
at the given path. On X-axis we have distance values and on Y-axis we
have percentage of node pairs that have that distance value"""
diameter = graph_diameter(paths_data)
pairs = graph.order() * (graph.order()-1) * 0.5
distances_count = [0 for i in xrange(diameter + 1)]
for i in xrange(8):
with open('%s_%d' % (paths_data, i), 'r') as in_file:
for line in in_file:
tokens = line.split()
distances_count[int(tokens[2])] += 1
for i in xrange(diameter + 1):
distances_count[i] *= (100.0 / pairs)
y = distances_count
plt.loglog(y, 'b-', marker = '.')
plt.title("Shortest Paths Spectrum")
plt.ylabel("Percent of pairs")
plt.xlabel("Distance")
plt.axis('tight')
plt.savefig(path)
开发者ID:jillzz,项目名称:protein-interaction,代码行数:25,代码来源:interaction_graph_info.py
示例7: plotting
def plotting(self, msdtype="ensemble", particlemsdtime=0,error=0, showlegend=None,scale="loglog"):
"""
:param error: Number of standard deviations from mean, which is shown in the figure
:return: A figure with plotting of the Ensemble MSD
"""
if msdtype=="ensemble":
msd,std=self.msd_ensemble()
if msdtype=="time":
msd,std=self.msd_time(particlemsdtime)
colors=['r','b','g','k','c','w','b','r','g','b','k','c','w','b','r','g','b','k','c','w','bo','ro','go','bo','ko','co','wo','bo']
#fig=plt.plot(range(msd_ensemble.size), msd_ensemble ,colors[2], label="ensemble msd")
if scale == "lin":
plt.plot(self.t*self.dt,self.msdanalyt(),":",color=colors[1], label="analytisch D=%f,particles=%d,length=%d,alpha=%f" %(self.D,self.particles,self.n,self.alpha))
if scale == "loglog":
plt.loglog(self.t*self.dt,self.msdanalyt(),":",color=colors[1], label="analytisch D=%f,particles=%d,length=%d,alpha=%f" %(self.D,self.particles,self.n,self.alpha))
fig=plt.errorbar(self.t*self.dt, msd, yerr=error*std,label="Spektrale Methode mit D=%f,particles=%d, length=%d ,alpha=%f, Std=%f" %(self.D,self.particles,self.n,self.alpha,error))
if showlegend is not None:
plt.legend(loc=2)
plt.xlabel('Steps', fontsize=14)
plt.ylabel('MSD', fontsize=14)
return fig
开发者ID:janekg89,项目名称:Masterarbeit_fbm,代码行数:25,代码来源:analyse_tool.py
示例8: Total_mass_plot
def Total_mass_plot(rbin, mTbin):
plt.loglog( rbin, mTbin)
#plt.axhline(chosen_ratio_number*particleMass, color = 'g')
plt.ylim(1e32, 1e37)
plt.xlim(3e-3, 3e0)
plt.ylabel(r'$M$ $({\rm g})$', fontsize=25)
plt.xlabel(r'$r$ $({\rm pc})$', fontsize=25)
开发者ID:dwmurray,项目名称:Stellar_scripts,代码行数:7,代码来源:ramses_plot.py
示例9: total_mass_plot
def total_mass_plot(rbin, mTbin):
pl.clf()
pl.loglog( rbin, mTbin)
pl.ylim(1e32, 1e37)
pl.xlim(1e-3, 3e0)
pl.ylabel('Total Mass ($g$)')
pl.xlabel('Radius ($pc$)')
开发者ID:philchang,项目名称:pittman-paper,代码行数:7,代码来源:plot.py
示例10: Magnetic_vs_radius
def Magnetic_vs_radius(rbin, Btotbin):
plt.loglog( rbin, Btotbin*Btotbin/(8.*np.pi), 'b', label='$B_{tot}^2 / 8 \pi$', lw = 2)
plt.legend(loc=0, fontsize=22, frameon=False)
# plt.ylim(1e-1, 3e0)
# plt.xlim(3e-3, 3e0)
plt.ylabel(' $B$ $({\\rm gauss })$', fontsize=25)
plt.xlabel('$r$ $(\\rm pc)$', fontsize=25)
开发者ID:dwmurray,项目名称:Stellar_scripts,代码行数:7,代码来源:ramses_plot.py
示例11: plot_resolution_cddf
def plot_resolution_cddf(snap=3, maxfac=1.):
"""Plot the effect of changing resolution on the CDDF."""
base_large = myname.get_name(7, box=25)
base_small = myname.get_name(7, box=7.5)
ahalo_large = CIVPlottingSpectra(snap, base_large, None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,load_halo=True)
ahalo_small = CIVPlottingSpectra(snap, base_small, None, None, savefile="rand_civ_spectra.hdf5", spec_res=5.,load_halo=True)
maxmass = np.max(ahalo_small.sub_mass)/maxfac
print("Max mass=",maxmass/1e10," was ",np.max(ahalo_large.sub_mass)/1e10)
print("Small box has ",np.size(np.where(ahalo_small.sub_mass > maxmass))," larger halos")
print("Larger box has ",np.size(np.where(ahalo_large.sub_mass > maxmass))," larger halos")
ahalo_large.get_col_density("C",4)
ahalo_small.get_col_density("C",4)
(halos_large,_) = ahalo_large.find_nearest_halo("C",4, thresh=50)
(halos_small,_) = ahalo_small.find_nearest_halo("C",4, thresh=50)
ind_large = np.where((ahalo_large.sub_mass[halos_large] < maxmass)*(halos_large > 0))
ind_small = np.where((ahalo_small.sub_mass[halos_small] < maxmass)*(halos_small > 0))
print("Now ",np.size(ind_large),np.size(ind_small)," spectra")
#Editing the private data like this is perilous
ahalo_large.colden[("C",4)] = ahalo_large.colden[("C",4)][ind_large]
ahalo_small.colden[("C",4)] = ahalo_small.colden[("C",4)][ind_small]
(NHI_large, cddf_large) = ahalo_large.column_density_function("C", 4, minN=11.5,maxN=16.5, line=False, close=50.)
plt.loglog(NHI_large,cddf_large,color="blue", label="25 Mpc Box", ls="-")
(NHI_small, cddf_small) = ahalo_small.column_density_function("C", 4, minN=11.5,maxN=16.5, line=False, close=50.)
plt.loglog(NHI_small,cddf_small,color="red", label="7.5 Mpc Box", ls="--")
ax=plt.gca()
ax.set_xlabel(r"$N_\mathrm{CIV} (\mathrm{cm}^{-2})$")
ax.set_ylabel(r"$f(N) (\mathrm{cm}^2)$")
plt.xlim(10**12, 10**15)
plt.legend(loc=0)
ax=plt.gca()
ax.set_xlabel(r"$N_\mathrm{CIV} (\mathrm{cm}^{-2})$")
ax.set_ylabel(r"$f(N) (\mathrm{cm}^2)$")
开发者ID:sbird,项目名称:civ_kinematics,代码行数:32,代码来源:make_extra_plots.py
示例12: main
def main():
citation_graph = load_graph(CITATION_URL)
print compute_in_degrees(citation_graph)
start_time = timeit.default_timer()
dist = in_degree_distribution(citation_graph)
print 'dist =', dist
total = sum(dist.itervalues())
normalized = {key: float(value)/total for key, value in dist.items()}
print(timeit.default_timer() - start_time)
x = normalized.keys()
y = normalized.values()
print len(y)
plt.loglog(x, y, 'ro')
plt.yscale('log')
plt.xscale('log')
plt.minorticks_off()
plt.xlabel('In-degree distribution')
plt.ylabel('Normalized In-degree distribution')
plt.title('Graph of Citations')
plt.grid(True)
plt.savefig('citations-q1.png')
plt.show()
开发者ID:denisra,项目名称:Algorithmic-Thinking,代码行数:30,代码来源:alg_load_graph.py
示例13: RGA_w
def RGA_w(w_start, w_end, x, y):
""" w_start is the start of logspace
w_end is the ending of the logspace
x and y is refer to the indices of the RGA matrix that needs to be plotted
this is to calculate the RGA at different freqeuncies
this give more conclusive values of which pairing would give fast responses
under dynamic situations"""
w = np.logspace(w_start, w_end, 1000)
store = np.zeros([len(x), len(w)])
count = 0
for w_i in w:
A = G(w_i)
RGA_w = np.multiply(A, np.transpose(np.linalg.pinv(A)))
store[:, count] = RGA_w[x, y]
count = count + 1
for i in range(len(x)):
plt.loglog(w, store[i, :])
plt.title("RGA over Freq")
plt.xlabel("w")
plt.ylabel("|RGA values| gevin x ,y ")
plt.show()
开发者ID:Terrance88,项目名称:Skogestad-Python,代码行数:26,代码来源:RGA.py
示例14: plot_betweenness_dist
def plot_betweenness_dist (graph, path):
"""Plot distribution of betweenness centrality of the graph and save the figure
at the given path. On X-axis we have betweenness centrality values and on
Y-axis we have percentage of the nodes that have that betweenness value.
k is the number of samples for estimating the betweenness centrality."""
N = float(graph.order())
node_to_betweenness = nx.betweenness_centrality(graph)
betweenness_to_percent = {}
# calculate percentages of nodes with certain betweeness value
for node in node_to_betweenness:
betweenness_to_percent[node_to_betweenness[node]] = 1 + \
betweenness_to_percent.get(node_to_betweenness[node], 0)
for c in betweenness_to_percent:
betweenness_to_percent[c] = betweenness_to_percent[c] / N * 100
x = sorted(betweenness_to_percent.keys(), reverse = True)
y = [betweenness_to_percent[i] for i in x]
plt.loglog(x, y, 'b-', marker = '.')
plt.title("Betweenness Centrality Distribution")
plt.ylabel("Percentage")
plt.xlabel("Betweenness value")
plt.axis('tight')
plt.savefig(path)
开发者ID:jillzz,项目名称:protein-interaction,代码行数:26,代码来源:interaction_graph_info.py
示例15: GpPlot
def GpPlot(row, col, figNum):
n = 4
GpsAdd = np.zeros((n**3,1000), dtype=complex)
GpsMult = np.zeros((n**3,1000), dtype=complex)
w = np.logspace(-3,1,1000)
for i in range(1000):
GpsAdd[:,i], GpsMult[:,i] = Gp(w[i]*1j, row, col, n)
plt.figure(figNum)
# plt.clf()
plt.subplot(211)
for i in range(n**3):
plt.loglog(w, GpsAdd[i,],'-', color = ([row*0.3, col*0.3, 1]), alpha=0.2)
plt.grid(True)
plt.ylabel('|Additive Uncertainty|')
plt.xlabel('Frequency [rad/s)]')
plt.subplot(212)
for i in range(n**3):
plt.loglog(w, GpsMult[i,],'-', color = ([row*0.3, col*0.3, 1]), alpha=0.2)
plt.grid(True)
plt.ylabel('|Multiplicative Uncertainty|')
plt.xlabel('Frequency [rad/s)]')
fig = plt.gcf()
BG = fig.patch
BG.set_facecolor('white')
fig.subplots_adjust(bottom=0.2)
fig.subplots_adjust(top=0.9)
fig.subplots_adjust(left=0.2)
fig.subplots_adjust(right=0.9)
开发者ID:pdawsonsa,项目名称:CBT700Project,代码行数:28,代码来源:W_Uncertainty.py
示例16: plot_clustering_spectrum
def plot_clustering_spectrum (graph, path):
"""Plot the clusttering spectrum of the graph and save the figure
at the given path. On X-axis we have degrees and on Y-axis we have
average clustering coefficients of the nodes that have that degree"""
node_to_degree = graph.degree()
node_to_clustering = nx.clustering(graph)
degree_to_clustering = {}
# calculate average clustering coefficients for nodes with certain degree
for node in node_to_degree:
deg = node_to_degree[node]
tmp = degree_to_clustering.get(deg, [])
tmp.append(node_to_clustering[node])
degree_to_clustering[deg] = tmp
for degree in degree_to_clustering:
tmp = degree_to_clustering[degree]
degree_to_clustering[degree] = float(sum(tmp)) / len(tmp)
x = sorted(degree_to_clustering.keys(), reverse = True)
y = [degree_to_clustering[i] for i in x]
plt.loglog(x, y, 'b-', marker = '.')
plt.title("Clustering Spectrum")
plt.ylabel("Average clustering coefficient")
plt.xlabel("Degree")
plt.axis('tight')
plt.savefig(path)
开发者ID:jillzz,项目名称:protein-interaction,代码行数:29,代码来源:interaction_graph_info.py
示例17: plot_P
def plot_P(self, kmin, kmax, step, units_k = 'default', units_P = 'default'):
stepsize = (kmax - kmin) / float(step)
x = [kmin + float(i) * stepsize for i in range(0, step)]
y1 = [self.P_delta(k, units_k, units_P) for k in x]
plot1 = plt.loglog(x, y1, basex = 10, basey = 10, label = r'P(k)')
if units_k == 'default':
plt.xlabel(r'$k$ $(h \, Mpc^{-1})$')
elif units_k == 'mpc-1' or units_k == 'Mpc-1':
plt.xlabel(r'$k$ $(Mpc^{-1})$')
if units_P == 'default':
plt.ylabel(r'$P(k)$ $(h^{-3} Mpc^3)$')
elif units_P == 'mpc3' or units_P == 'Mpc3':
plt.ylabel(r'$P(k)$ $(Mpc^3)$')
if units_k == 'default' and units_P == 'default':
xcomp, ycomp = np.loadtxt('compare.dat', unpack = True)
plot2 = plt.loglog(xcomp, ycomp, basex = 10, basey = 10, label = r'P(k) from iCosmo')
xcomp2, ycomp2 = np.loadtxt('test_matterpower.dat', unpack = True)
plot3 = plt.loglog(xcomp2, ycomp2, basex = 10, basey = 10, label = r'P(k) from CAMB')
plt.legend(loc = 'upper right')
plt.title(r'Matter Power Spectrum' )
plt.grid(True)
plt.xlim([10**(-3), 10])
plt.ylim([1, 100000])
plt.savefig('powerspectrum.png')
plt.show()
开发者ID:claudejpschmit,项目名称:PhD-CosmoCalc,代码行数:33,代码来源:CosmologyPlotterClass.py
示例18: compareXS
def compareXS(isotope, type_xs='capture', dir='.'):
#Get fake XS from info given
El, A = isotope.split('-', 1)
#Find proper filename for fake XS
if type_xs=='scatter':
type_xs='elastic'
path=str(pinspec.getXSLibDirectory())+'/'+El+'-'+A+'-'+type_xs+'.txt'
#Read in array for fictitious XS at 300
EnT=numpy.array([])
barnsT=numpy.array([])
invEnT=numpy.array([])
with open(path) as resT:
#Parse out String containing Temperature
Junk, temp = resT.readline().split('=', 1)
for line in resT:
EnTt, barnsTt=line.split(',', 1)
EnTt=float(EnTt)
barnsTt=float(barnsTt)
invEnTt=1/EnTt
EnT=numpy.append(EnT,EnTt)
barnsT=numpy.append(barnsT,barnsTt)
invEnT=numpy.append(invEnT, invEnTt)
py_printf('INFO', 'Read in Doppler Broadened XS correctly')
#Read in array for ENDF7 XS at 300
npath=str(pinspec.getXSLibDirectory())+'/BackupXS/'+El+'-'+A+'-' + \
type_xs+'.txt'
EndfE300=numpy.array([])
barnsEndF300=numpy.array([])
invEndfE300=numpy.array([])
with open(npath) as Endf300:
#Parse out String containing Temperature
Junk, xssource = Endf300.readline().split(' ', 1)
xssource=xssource.strip()
for line in Endf300:
EndfE300temp, barnsEndF300temp=line.split(',', 1)
EndfE300temp=float(EndfE300temp)
barnsEndF300temp=float(barnsEndF300temp)
invEndfE300temp=1/EndfE300temp
EndfE300=numpy.append(EndfE300,EndfE300temp)
barnsEndF300=numpy.append(barnsEndF300,barnsEndF300temp)
invEndfE300=numpy.append(invEndfE300,invEndfE300temp)
log_printf(INFO,'Read in ENDF/B-VII XS correctly')
#Plot values on top of each other
fig=plt.figure()
plt.loglog(EnT,barnsT)
plt.loglog(EndfE300,barnsEndF300)
CXStype=type_xs.title()
plt.legend(['Doppler broadened '+El+'-'+A+' '+CXStype+' XS at temp=' + \
temp,xssource+' '+El+'-'+A+' '+CXStype+' XS at temp=300K'], \
loc='lower left',prop={'size':10})
plt.grid()
plt.title(CXStype+' Cross Section Comparison')
plt.xlabel('XS [barns]')
plt.ylabel('E [eV]')
plt.savefig(dir+'/'+CXStype+'_XS_Comparison.png')
开发者ID:cjosey,项目名称:PINSPEC,代码行数:60,代码来源:slbw.py
示例19: hurst_curv_exponent
def hurst_curv_exponent(xy,verbose=False):
"""computes the Hurst coefficient which qualify how the trajectory is persistent in time
it is related to the fractal dimension of the trajectory, here the denominator is the curvilinear distance
"""
#compute all distances
d = squareform(pdist(xy, 'euclidean'))
#max number of successive positions
N = 10
data = npy.zeros((N,2))
for k in range(N):
kd = npy.diag(d,k+1)
c_length = k+1
data[k,:] = (c_length,npy.mean(kd))
#linear fit in log-log
x = npy.log(data[:,0])
y = npy.log(data[:,1])
A = npy.vstack([x, npy.ones(len(x))]).T
m, c = npy.linalg.lstsq(A, y)[0]
if verbose:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
plt.loglog(data[:,0],data[:,1])
plt.legend()
plt.show()
return m
开发者ID:odebeir,项目名称:ivctrack,代码行数:31,代码来源:measurement.py
示例20: plot_area_vs_energy
def plot_area_vs_energy(self, filename=None, show_save_energy=True):
"""
Plot effective area vs. energy.
"""
import matplotlib.pyplot as plt
energy_hi = self.energy_hi.value
effective_area = self.effective_area.value
plt.plot(energy_hi, effective_area)
if show_save_energy:
plt.vlines(self.energy_thresh_hi.value, 1E3, 1E7, 'k', linestyles='--')
plt.text(self.energy_thresh_hi.value - 1, 3E6,
'Safe energy threshold: {0:3.2f}'.format(
self.energy_thresh_hi),
ha='right')
plt.vlines(self.energy_thresh_lo.value, 1E3, 1E7, 'k', linestyles='--')
plt.text(self.energy_thresh_lo.value + 0.1, 3E3,
'Safe energy threshold: {0:3.2f}'.format(self.energy_thresh_lo))
plt.xlim(0.1, 100)
plt.ylim(1E3, 1E7)
plt.loglog()
plt.xlabel('Energy [TeV]')
plt.ylabel('Effective Area [m^2]')
if filename is not None:
plt.savefig(filename)
log.info('Wrote {0}'.format(filename))
开发者ID:JonathanDHarris,项目名称:gammapy,代码行数:26,代码来源:effective_area_table.py
注:本文中的matplotlib.pyplot.loglog函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论