本文整理汇总了Python中matplotlib.pylab.loglog函数的典型用法代码示例。如果您正苦于以下问题:Python loglog函数的具体用法?Python loglog怎么用?Python loglog使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loglog函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sanity_exampleExoplanetEU2
def sanity_exampleExoplanetEU2(self):
"""
Example of ExoplanetEU2
"""
from PyAstronomy import pyasl
import matplotlib.pylab as plt
# Instantiate exoplanetEU2 object
v = pyasl.ExoplanetEU2()
# Show the available data
v.showAvailableData()
print()
# Get a list of all available column names
acs = v.getColnames()
print("Available column names: " + ", ".join(acs))
print()
# Select data by planet name (returns a dictionary)
print(v.selectByPlanetName("CoRoT-2 b"))
print()
# Get all data as an astropy table
at = v.getAllDataAPT()
# Export all data as a pandas DataFrame
pd = v.getAllDataPandas()
# Plot mass vs. SMA
plt.title("Mass vs. SMA")
plt.xlabel("[" + v.getUnitOf("mass") + "]")
plt.ylabel("[" + v.getUnitOf("semi_major_axis") + "]")
plt.loglog(at["mass"], at["semi_major_axis"], 'b.')
示例2: experiment_plot
def experiment_plot( ctr, trials, success ):
"""
Pass in the ctr, trials and success returned
by the `experiment` function and plot
the Cumulative Number of Turns For Each Arm and
the CTR's Convergence Plot side by side
"""
T, K = trials.shape
n = np.arange(T) + 1
fig = plt.figure( figsize = ( 14, 7 ) )
plt.subplot(121)
for i in range(K):
plt.loglog( n, trials[ :, i ], label = "arm {}".format(i + 1) )
plt.legend( loc = "upper left" )
plt.xlabel("Number of turns")
plt.ylabel("Number of turns/arm")
plt.title("Cumulative Number of Turns For Each Arm")
plt.subplot(122)
for i in range(K):
plt.semilogx( n, np.zeros(T) + ctr[i], label = "arm {}'s CTR".format( i + 1 ) )
plt.semilogx( n, ( success[ :, 0 ] + success[ :, 1 ] ) / n, label = "CTR at turn t" )
plt.axis([ 0, T, 0, 1 ] )
plt.legend( loc = "upper left" )
plt.xlabel("Number of turns")
plt.ylabel("CTR")
plt.title("CTR's Convergence Plot")
return fig
示例3: _test_convergence
def _test_convergence(self, fun, x, *args):
for i in x:
y = fun(i, *args)
plt.figure('res')
plt.plot(abs(i), y, '.')
plt.loglog()
示例4: in_degrees_dist_plot
def in_degrees_dist_plot(in_degrees_dist, num_nodes):
import matplotlib.pylab as plt
x_axis = []
y_axis = []
for node, degree in in_degrees_dist.items():
if node != 0:
distribution = float(degree) / float(num_nodes)
x_axis.append(node)
y_axis.append(distribution)
plt.loglog(x_axis, y_axis, 'ro')
plt.xlabel('In-degrees')
plt.ylabel('Distribution')
plt.title('In degrees Distribution (log/log Plot)')
plt.show()
示例5: plotsa
def plotsa():
"""
Plots Simulated annealing example
"""
fig1 = pl.figure()
data = np.loadtxt("simulatedannealing1.csv", skiprows=1, delimiter=",")
fvals = data[:, 0]
nevals = range(len(fvals))
pl.loglog(nevals, fvals, 'b-')
pl.xlabel("function evaluations", fontsize=20)
pl.ylabel("cost function value", fontsize=20)
pl.ylim([50, 5000])
ax = fig1.gca()
ax.tick_params(axis='x', labelsize=16)
ax.tick_params(axis='y', labelsize=16)
pl.savefig("simulatedannealing1.png", bbox_inches='tight')
示例6: plotga
def plotga():
"""
Plots genetic algorithm
"""
fig1 = pl.figure()
data = np.loadtxt("geneticalgorithm.csv", skiprows=1, delimiter=",")
fvals = data[:, 0]
nevals = range(len(fvals))
pl.loglog(nevals, fvals, 'b-')
pl.xlabel("function evaluations", fontsize=20)
pl.ylabel("cost function value", fontsize=20)
pl.ylim([50, 3000])
ax = fig1.gca()
ax.tick_params(axis='x', labelsize=16)
ax.tick_params(axis='y', labelsize=16)
# pl.tight_layout()
pl.savefig("geneticalgorithm.png", bbox_inches='tight')
示例7: plot_convergence
def plot_convergence(self,x,y,rate=None,log=True,figname='_plot',case='',title='',tolatex=False):
self.create_dir(self.plotdir)
log_name = ''
log_label = ''
log_title = ''
if not tolatex:
log_title = 'Log Log '
if log:
log_name = 'loglog_'
plt.figure()
if rate is not None:
p = self.p_line_range
m = rate[0]
c = rate[1]
plt.hold(True)
plt.loglog(x[p[0]:p[1]],10.0**(m*np.log10(x[p[0]:p[1]])+c-2.0),'r')
if log:
plt.loglog(x,y,'bo--')
else:
plt.plot(x,y,'o:')
if not tolatex:
plt.title(title+log_title+case+' convergence')
plt.xlabel('$'+log_label+'mx$')
plt.ylabel('$'+log_label+'\Delta q$')
plt.grid(True)
plt.draw()
case = case.replace(" ", "_")
fig_save_name = figname+'_'+log_name+case+'.'+self.plot_format
figpath = os.path.join(self.plotdir,fig_save_name)
plt.savefig(figpath,format=self.plot_format,dpi=320,bbox_inches='tight')
plt.close()
if tolatex:
caption = ''
if log:
caption = 'Log Log '
caption = caption + 'plot of '+case.replace("_"," ")+' convergence test'
caption.capitalize()
self.gen_latex_fig(figpath,caption=caption)
return
示例8: sanity_example
def sanity_example(self):
"""
Exoplanet EU example
"""
from PyAstronomy import pyasl
import matplotlib.pylab as plt
eu = pyasl.ExoplanetEU()
# See what information is available
cols = eu.availableColumns()
print cols
print
# Get all data and plot planet Mass vs.
# semi-major axis in log-log plot
dat = eu.getAllData()
plt.xlabel("Planet Mass [RJ]")
plt.ylabel("Semi-major axis [AU]")
plt.loglog(dat.plMass, dat.sma, 'b.')
示例9: log_datafit
def log_datafit(x, y, deg):
z = np.polyfit(np.log10(x), np.log10(y), deg)
p = np.poly1d(z)
A = np.zeros(np.shape(p)[0])
for i in range(np.shape(p)[0]):
A[::-1][i] = p[i]
yvals = 0.
for j in range(np.shape(p)[0]):
yvals += (((np.log10(x))**j)*A[::-1][j])
plt.ion()
plt.loglog(x, y, 'bo', label='Data')
plt.loglog(x, 10**(yvals), 'g--', lw=2, label='Best Fit')
plt.legend(loc='best')
plt.grid(which='minor')
plt.minorticks_on()
print "Ax+B"
print "A = ", A[0]
print "B =", A[1]
示例10: calculate_speed_up
def calculate_speed_up():
N = np.array([80,160,320,640,1280])
h = 2./N
cpu_time = np.array([8.97, 33.28 , 141.02 , 554.96, 2164.34])
gpu_time = np.array([1.4877, 3.1019, 10.46, 33.3699, 125.660])
speedup = np.array([6.25, 11.43, 13.48, 16.63, 17.22])
plt.figure()
plt.loglog(N, cpu_time,'ro-', label='Xeon E5-2650 2.60GHz')
plt.loglog(N, gpu_time,'b+-', label='Tesla K40')
plt.loglog(N, (cpu_time[0]*1.2)*(N/N[0])**2, 'k-', label='2rd order')
#legend(handles=[numerical_solution, order5])
grid(True)
ylabel('Runtime for 100 time step (second)')
xlabel('Domain size')
title("CPU and GPU Performance")
xlim([80, 2560])
xticks([20,40,80,160,320,640,1280, 2560], [20,40,80,160,320,640,1280, 2560])
legend(bbox_to_anchor=(0., 1, 0.5, .0))
plt.figure()
plt.plot(N, speedup,'b+-', label='Tesla K40')
#loglog(N, (speedup[0]*1.2)*(N/N[0])**2, 'k-', label='2rd order')
#legend(handles=[numerical_solution, order5])
grid(True)
ylabel('Speedup ($t_{cpu}/t_{gpu}$)')
xlabel('domain size')
title("GPU Speedup")
xticks([80,160,320,640,1280], [80,160,320,640,1280])
legend(bbox_to_anchor=(0., 1, 0.3, .0))
show()
示例11: plot_regularization_curve
def plot_regularization_curve(self, name_add=''):
# Matplotlib is loaded selectively as it is requires
# libraries that are often not installed on clusters
import matplotlib.pylab as plt
an_name = self.settings.get('an_name', 'xx')
filename = an_name + '_regu_curve' + name_add + '.png'
sort_order = np.argsort(self.omega2_list)
omega2_arr = np.array(self.omega2_list).take(sort_order)
epe_arr = np.array(self.epe_list).take(sort_order)
err_arr = np.array(self.err_list).take(sort_order)
ERR_arr = np.array(self.ERR_list).take(sort_order)
plt.title('omega2: %.2e Neff: %.1f' % (self.opt_omega2, self.n_eff))
plt.loglog(omega2_arr, epe_arr, '-', label='EPE')
plt.loglog(omega2_arr, np.sqrt(err_arr), '--', label='err')
plt.loglog(omega2_arr, np.sqrt(ERR_arr), '-.', label='ERR')
plt.legend(loc=2)
plt.xlabel('Omega2')
plt.ylabel('eV')
# plt.show()
plt.savefig(filename)
plt.clf()
示例12: plot
def plot(out_filepath, graph):
fig = pylab.figure(1)
pylab.subplot(211)
networkx.draw_spring(graph, node_size = 8, with_labels = False)
deg = {}
for d in [ len(graph.edges(n)) for n in graph.nodes() ]:
try:
deg[d] += 1
except KeyError:
deg[d] = 1
print(deg)
pylab.subplot(212)
plot = deg.items()
pylab.loglog([ x[0] for x in plot ], [ x[1] for x in plot ], '.')
pylab.savefig(out_filepath + '.png')
示例13: many_spectra
def many_spectra():
import healpy as hp
chunks = ['f','g','h']
thresh = {'f':1.0, 'g':1.0, 'h':1.8}
fwhm_deg = {'f':7.0, 'g':7.0, 'h':5.0}
final_fwhm_deg = {'f':7.0, 'g':7.0, 'h':7.0}
cl={}
pl.figure(1)
pl.clf()
xlim = [10,700]
ylim = [1e-7, 3e-4]
for k in chunks:
print k
nmap = get_hpix(quick=True,name=k)
mask = mask_from_map(nmap, fwhm_deg=fwhm_deg[k], final_fwhm_deg=final_fwhm_deg[k], thresh=thresh[k])
# mean_nmap = np.mean(nmap[np.where(mask!=0)[0]])
mean_nmap = np.mean(nmap[np.where(mask>0.5)[0]])
delta = (nmap-mean_nmap)/mean_nmap
hp.mollview(hp.smoothing(delta*mask,fwhm=1.*np.pi/180.),title=k,min=-0.3,max=0.3)
continue
this_cl = hp.anafast(delta*mask)/np.mean(mask**2.)
l=np.arange(len(this_cl))
# smooth in l*cl
lcl = this_cl*l
sm_lcl = np.zeros_like(lcl)
rbox = 15
for i in l:
imin = np.max([0,i-rbox])
imax = np.min([np.max(l), i+rbox])
sm_lcl[i]=np.mean(lcl[imin:imax])
# cl[k:this_cl]
# pl.loglog(l,this_cl,linewidth=2)
pl.loglog(l,sm_lcl,linewidth=2)
pdb.set_trace()
pl.xlim(xlim)
# pl.ylim(ylim)
pl.legend(chunks)
pl.xlabel('L')
pl.ylabel('L*CL')
示例14: expt1
def expt1():
"""
Experiment 1: Chooses the result files and generates figures
"""
# filename = sys.argv[1]
result_file = "./expt1.txt"
input_threads, input_sizes, throughputs, resp_times \
= parse_output(result_file)
throughputs_MiB = [tp/2**20 for tp in throughputs]
fig1 = pl.figure()
fig1.set_tight_layout(True)
fig1.add_subplot(221)
pl.semilogx(input_sizes, throughputs_MiB,
'bo-', ms=MARKER_SIZE, mew=0, mec='b')
pl.xlabel("fixed file size (Bytes)")
pl.ylabel("throughput (MiB/sec)")
pl.text(2E3, 27, "(A)")
fig1.add_subplot(222)
pl.loglog(input_sizes, resp_times,
'mo-', ms=MARKER_SIZE, mew=0, mec='m')
pl.xlabel("fixed file size (Bytes)")
pl.ylabel("response time (sec)")
pl.text(2E3, 500, "(B)")
fig1.add_subplot(223)
pl.semilogx(resp_times, throughputs_MiB,
'go-', ms=MARKER_SIZE, mew=0, mec='g')
pl.xlabel("response time(sec)")
pl.ylabel("throughput (MiB/sec)")
pl.text(0.2, 27, "(C)")
pl.tight_layout()
pl.savefig("./figures/%s" % result_file.replace(".txt", ".pdf"))
示例15: plot_reusage
def plot_reusage(db, keynames, save_path, attr_name = [ 'linkWeightDistr_x', 'linkWeightDistr_y' ]):
plt.clf()
plt.figure(figsize = (8, 5))
plt.loglog(db[keynames['mog']][attr_name[0]], db[keynames['mog']][attr_name[1]], 'b-', lw = 5, label = 'fariyland')
plt.loglog(db[keynames['mblg']][attr_name[0]], db[keynames['mblg']][attr_name[1]], 'r:', lw = 5, label = 'twitter')
plt.loglog(db[keynames['im']][attr_name[0]], db[keynames['im']][attr_name[1]], 'k--', lw = 5, label = 'yahoo')
plt.xlabel('Usage (days)')
plt.ylabel('CCDF')
plt.title('Usage of Links')
plt.grid(True)
plt.legend(('fairyland', 'twitter', 'yahoo'), loc = 'best')
plt.savefig(os.path.join(save_dir, save_path))