本文整理汇总了Python中matplotlib.pylab.semilogy函数的典型用法代码示例。如果您正苦于以下问题:Python semilogy函数的具体用法?Python semilogy怎么用?Python semilogy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了semilogy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unteraufgabe_g
def unteraufgabe_g():
# Sampling punkte
x = np.linspace(0.0,1.0,1000)
N = np.arange(2,16)
LU = np.ones_like(N,dtype=np.floating)
LT = np.ones_like(N,dtype=np.floating)
# Approximiere Lebesgue-Konstante
for i,n in enumerate(N):
################################################################
#
# xU = np.linspace(0.0,1.0,n)
#
# LU[i] = ...
#
# j = np.arange(n+1)
# xT = 0.5*(np.cos((2.0*j+1.0)/(2.0*(n+1.0))*np.pi) + 1.0)
#
# LT[i] = ...
#
################################################################
continue
# Plot
plt.figure()
plt.semilogy(N,LU,"-ob",label=r"Aequidistante Punkte")
plt.semilogy(N,LT,"-og",label=r"Chebyshev Punkte")
plt.grid(True)
plt.xlim(N.min(),N.max())
plt.xlabel(r"$n$")
plt.ylabel(r"$\Lambda^{(n)}$")
plt.legend(loc="upper left")
plt.savefig("lebesgue.eps")
示例2: unteraufgabe_d
def unteraufgabe_d():
n = np.arange(2,21,2)
xs = [x02,x04,x06,x08,x10,x12,x14,x16,x18,x20]
f = lambda x: np.sin(10*x*np.cos(x))
residuals = np.zeros_like(n,dtype=np.floating)
condition = np.ones_like(n,dtype=np.floating)
for i, x in enumerate(xs):
b = f(x)
A = interp_monom(x)
alpha = solve(A,b)
residuals[i] = norm(np.dot(A,alpha) - b)
condition[i] = cond(A)
plt.figure()
plt.plot(n,residuals,"-o")
plt.grid(True)
plt.xlabel(r"$n$")
plt.ylabel(r"$\|A \alpha - b\|_2$")
plt.savefig("residuals.eps")
plt.figure()
plt.semilogy(n,condition,"-o")
plt.grid(True)
plt.xlabel(r"$n$")
plt.ylabel(r"$\log(\mathrm{cond}(A))$")
plt.savefig("condition.eps")
示例3: plot
def plot(coefs_files, digit=0, mixture=0, axis=0):
import numpy as np
import matplotlib.pylab as plt
import amitgroup as ag
for coefs_file in coefs_files:
coefs_data = np.load(coefs_file)
var = coefs_data['prior_var']
samples = coefs_data['samples']
llh_var = coefs_data['llh_var']
var_flat = ag.util.wavelet.smart_flatten(var[digit,mixture,axis])
last_i = len(var_flat)-1
plt.xlim((0, last_i))
#imdef = ag.util.DisplacementFieldWavelet((32, 32), 'db4', penalty=100
if len(coefs_files) == 1:
add = ""
else:
add = " ({0})".format(coefs_file.name)
plt.subplot(121)
plt.semilogy(1/var_flat, label="ML"+add)
plt.legend(loc=0)
plt.xlabel('Coefficient')
plt.ylabel('Precision $\lambda$')
plt.xlim((0, 63))
plt.subplot(122)
plt.imshow(1/llh_var[digit,mixture], interpolation='nearest')
plt.xlabel("Likelihood precision $\lambda'$")
plt.colorbar()
plt.show()
示例4: demo
def demo():
'''
Load and plot a few CIB spectra.
'''
# define ell array.
l = np.arange(100,4000)
# get dictionary of CIBxCIB spectra.
cl_cibcib = get_cl_cibcib(l)
# plot
import matplotlib.pylab as pl
pl.ion()
lw=2
fs=18
leg = []
pl.clf()
for band in ['857','545','353']:
pl.semilogy(l, cl_cibcib['545',band],linewidth=lw)
leg.append('545 x '+band)
pl.xlabel(r'$\ell$',fontsize=fs)
pl.ylabel(r'$C_\ell^{TT, CIB} [\mu K^2]$',fontsize=fs)
pl.ylim(5e-2,6e3)
pl.legend(leg, fontsize=fs)
示例5: plotHousing
def plotHousing(impression):
"""
生成房价随时间变化的图标
"""
f = open("midWestHousingPrices.txt", 'r')
#文件每一行是年季度价格
labels, prices = [], []
for line in f:
year, quarter, price = line.split()
label = year[2:4] + "\n Q" + quarter[1]
labels.append(label)
prices.append(float(price)/1000)
#柱的X坐标
quarters = np.arange(len(labels))
#柱宽
width = 0.5
if impression == 'flat':
plt.semilogy()
plt.bar(quarters, prices, width, color='r')
plt.xticks(quarters + width / 2.0, labels)
plt.title("美国中西部各州房价")
plt.xlabel("季度")
plt.ylabel("平均价格($1000)")
if impression == 'flat':
plt.ylim(10, 10**3)
elif impression == "volatile":
plt.ylim(180, 220)
elif impression == "fair":
plt.ylim(150, 250)
else:
raise ValueError("Invalid input.")
示例6: testPlotFrequencyDomain
def testPlotFrequencyDomain():
filename = baseFilename % 0
rawData = dataImport.readADSFile(filename)
rawSps = 32000
downSampled = _downSample(rawData, rawSps)
downSampledLinear = _downSampleLinearInterpolate(rawData, rawSps)
rawTimes = range(len(rawData))
times = [float(x) * rawSps / samplesPerSecond for x in range(len(downSampled))]
#pylab.plot(times, downSampled)
#pylab.plot(rawTimes, rawData)
#pylab.plot(times, downSampledLinear)
pylab.show()
index = 0
fdat = applyTransformsToWindows(getFFTWindows(downSampled), True)[index]
fdatLin = applyTransformsToWindows(getFFTWindows(downSampledLinear), True)[index]
#print [str(x) for x in zip(fdat, fdatLin)]
frequencies = [i * samplesPerSecond / windowSize for i in range(len(fdat))]
pylab.semilogy(frequencies, fdat)
pylab.semilogy(frequencies, fdatLin)
pylab.grid(True)
pylab.show()
示例7: plot_misfit_curves
def plot_misfit_curves(items, threshold, threshold_is_upper_limit,
logarithmic, component, pretty_misfit_name, filename):
plt.close()
crossing_periods = []
crossing_values = []
for item in items:
if logarithmic:
plt.semilogy(item["periods"], item["misfit_values"])
else:
plt.plot(item["periods"], item["misfit_values"])
# Find the threshold.
point = rightmost_threshold_crossing(
item["periods"], item["misfit_values"], threshold,
threshold_is_upper_limit)
crossing_periods.append(point[0])
crossing_values.append(point[1])
plt.title("%s misfit curves for component %s" % (
pretty_misfit_name, component))
plt.xlabel("Lowpass Period [s]")
plt.ylabel("%s" % pretty_misfit_name)
x = items[0]["periods"][0] - 0.5, items[0]["periods"][-1] + 0.5
plt.hlines(threshold, x[0], x[1],
linestyle="--", color="0.5")
plt.scatter(crossing_periods, crossing_values, color="0.2", s=10,
zorder=5)
plt.xlim(*x)
plt.savefig(filename)
示例8: plottingTimeConsumptions
def plottingTimeConsumptions(titleString, trialedFuncs, timesToPlot):
""" titleString...String to be displayed in Title
trialedFuncs...list of the strings of the trialed functions
timesToPlot...dim [numberTrials, numberFunctions]
"""
# plt.figure()
for cnt in range(len(trialedFuncs)):
if 'vectorized' in trialedFuncs[cnt]:
lineStyle = '--'
elif 'faverage' in trialedFuncs[cnt]:
lineStyle = '--'
else:
lineStyle = '-'
plt.semilogy(timesToPlot[cnt], label=trialedFuncs[cnt], linestyle=lineStyle, marker='o')
plt.xticks(range(len(timesToPlot[1])))
plt.xlabel('trials [1]')
plt.ylabel('Time per Trial [s]')
plt.grid(which='major')
plt.grid(which='minor', linestyle='--')
plt.title(titleString)
yMin, yMax = plt.ylim()
newYMin = 10 ** np.floor(np.log10(yMin))
plt.ylim(newYMin, yMax)
plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.)
plt.show()
示例9: plotFittingResults
def plotFittingResults(self):
"""
Plot results of Rmax optimization procedure and best fit of the experimental data
"""
_listFitQ = [tmp.getValue() for tmp in self.getDataOutput().getScatteringFitQ()]
_listFitValues = [tmp.getValue() for tmp in self.getDataOutput().getScatteringFitValues()]
_listExpQ = [tmp.getValue() for tmp in self.getDataInput().getExperimentalDataQ()]
_listExpValues = [tmp.getValue() for tmp in self.getDataInput().getExperimentalDataValues()]
#_listExpStdDev = None
#if self.getDataInput().getExperimentalDataStdDev():
# _listExpStdDev = [tmp.getValue() for tmp in self.getDataInput().getExperimentalDataStdDev()]
#if _listExpStdDev:
# pylab.errorbar(_listExpQ, _listExpValues, yerr=_listExpStdDev, linestyle='None', marker='o', markersize=1, label="Experimental Data")
# pylab.gca().set_yscale("log", nonposy='clip')
#else:
# pylab.semilogy(_listExpQ, _listExpValues, linestyle='None', marker='o', markersize=5, label="Experimental Data")
pylab.semilogy(_listExpQ, _listExpValues, linestyle='None', marker='o', markersize=5, label="Experimental Data")
pylab.semilogy(_listFitQ, _listFitValues, label="Fitting curve")
pylab.xlabel('q')
pylab.ylabel('I(q)')
pylab.suptitle("RMax : %3.2f. Fit quality : %1.3f" % (self.getDataInput().getRMax().getValue(), self.getDataOutput().getFitQuality().getValue()))
pylab.legend()
pylab.savefig(os.path.join(self.getWorkingDirectory(), "gnomFittingResults.png"))
pylab.clf()
示例10: main
def main():
t1 = time()
assert 0, "This example needs easily accessible I and F"
imdef, info = ag.stats.bernoulli_model(F, I, stepsize_scale_factor=1.0, penalty=0.1, rho=1.0, last_level=4, tol=0.001, \
start_level=2, wavelet='db2')
Fdef = imdef.deform(F)
t2 = time()
print "Time:", t2-t1
PLOT = True
if PLOT:
import matplotlib.pylab as plt
x, y = imdef.meshgrid()
Ux, Uy = imdef.deform_map(x, y)
ag.plot.deformation(F, I, imdef)
#Also print some info before showing
print "Iterations (per level):", info['iterations_per_level']
plt.show()
# Print
plt.semilogy(info['costs'])
plt.show()
示例11: kmeans_graph
def kmeans_graph(k, newClusters):
plt.figure()
plt.title('Clustering Result, k = %i'%(k+1))
plt.xlabel('Number of counties in cluster')
plt.ylabel('Population Count')
plt.semilogy()
colors = ['ro', 'bo', 'go', 'yo', 'r^', 'b^']
for i, v in enumerate(newClusters):
print i, v
plt.plot(v, colors[i])
示例12: PlotFit
def PlotFit(traj_diff, p):
"""
Given a trajectory difference and p=(lyapExponent, lyapPrefactor),
plot |traj_diff| and the fit on a semilog y axis.
"""
pylab.plot(scipy.fabs(traj_diff), 'b-', linewidth=4)
fit = scipy.exp(p[1] + p[0] * scipy.arange(len(traj_diff)))
pylab.semilogy(fit, 'r-', linewidth=2)
pylab.show()
示例13: makePlot
def makePlot(xVals, yVals, title, xLabel, yLabel, style, logX=False, logY=False):
"""用给定的标题和标签绘制xVals和yVals
"""
plt.figure()
plt.title(title)
plt.xlabel(xLabel)
plt.ylabel(yLabel)
plt.plot(xVals, yVals, style)
if logX:
plt.semilogx()
if logY:
plt.semilogy()
示例14: viz
def viz(self, names, title=None, lw=None,
save=False, savename=None):
'''
NAMES can be
a name: 'mary'
space-separated names: 'mary james', or
a list of names: ['mary','james'].
Any capitalization works.
'''
pl.clf()
leg = []
colors = colorz()
if isinstance(names, basestring):
names = names.split()
if lw is None: lw = 4.0 - 0.3*np.log(len(names))
for iname,name_ in enumerate(names):
name = name_.lower().capitalize()
if name not in self.data:
print '%s is not in database.'%name
return
leg.append(name)
v = self.data[name]
years = np.sort(v.keys())
rank = np.array([v[year]['rank'] for year in years])
cnt = np.array([v[year]['cnt'] for year in years])
# rank
pl.subplot(1,2,1)
pl.semilogy(years, rank, '-', linewidth=lw, color=colors[iname])
pl.ylabel('Rank')
pl.ylim(1e5,1)
pl.grid('on')
# percentage
pl.subplot(1,2,2)
pl.semilogy(years, cnt*100, '-', linewidth=lw, color=colors[iname])
pl.ylabel('Share (%)')
pl.ylim(1e-4,10)
pl.grid('on')
# legend & title
for i in [1,2]:
pl.subplot(1,2,i)
pl.legend(leg, loc='lower left', fontsize=11, framealpha=0.9)
if title is not None:
pl.title(title)
pl.show()
if save:
if savename is None:
savename = '%s.png'%('_'.join(names))
print 'saving %s'%savename
pl.savefig(savename)
示例15: main
def main():
"""
NAME
lowes.py
DESCRIPTION
Plots Lowes spectrum for input IGRF-like file
SYNTAX
lowes.py [options]
OPTIONS:
-h prints help message and quits
-f FILE specify file name with input data
-d date specify desired date
-r read desired dates from file
-n normalize to dipole term
INPUT FORMAT:
l m g h
"""
norm=0
if '-f' in sys.argv:
ind=sys.argv.index('-f')
file=sys.argv[ind+1]
data=np.loadtxt(file)
dates=[2000]
elif '-d' in sys.argv:
ind=sys.argv.index('-d')
dates=[float(sys.argv[ind+1])]
elif '-r' in sys.argv:
ind=sys.argv.index('-r')
dates=np.loadtxt(sys.argv[ind+1])
if '-n' in sys.argv: norm=1
if len(sys.argv)!=0 and '-h' in sys.argv:
print(main.__doc__)
sys.exit()
plt.semilogy()
plt.xlabel('Degree (l)')
plt.ylabel('Power ($\mu$T$^2$)')
labels=[]
for date in dates:
if date!=2000:
gh=pmag.doigrf(0,0,0,date,coeffs=1)
data=pmag.unpack(gh)
Ls,Rs=pmag.lowes(data)
labels.append(str(date))
print(date,Rs[0])
if norm==1:
Rs=old_div(np.array(Rs),Rs[0])
#plt.plot(Ls,Rs,'ro')
plt.plot(Ls,Rs,linewidth=2)
plt.legend(labels,'upper right')
plt.draw()
input()