本文整理汇总了Python中matplotlib.pylab.grid函数的典型用法代码示例。如果您正苦于以下问题:Python grid函数的具体用法?Python grid怎么用?Python grid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grid函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:Xelaju,项目名称:NumMeth,代码行数:34,代码来源:interp.py
示例2: plot_feat_hist
def plot_feat_hist(data_name_list, filename=None):
pylab.clf()
# import pdb;pdb.set_trace()
num_rows = 1 + (len(data_name_list) - 1) / 2
num_cols = 1 if len(data_name_list) == 1 else 2
pylab.figure(figsize=(5 * num_cols, 4 * num_rows))
for i in range(num_rows):
for j in range(num_cols):
pylab.subplot(num_rows, num_cols, 1 + i * num_cols + j)
x, name = data_name_list[i * num_cols + j]
pylab.title(name)
pylab.xlabel('Value')
pylab.ylabel('Density')
# the histogram of the data
max_val = np.max(x)
if max_val <= 1.0:
bins = 50
elif max_val > 50:
bins = 50
else:
bins = max_val
n, bins, patches = pylab.hist(
x, bins=bins, normed=1, facecolor='green', alpha=0.75)
pylab.grid(True)
if not filename:
filename = "feat_hist_%s.png" % name
pylab.savefig(os.path.join(CHART_DIR, filename), bbox_inches="tight")
开发者ID:Axighi,项目名称:Scripts,代码行数:31,代码来源:utils.py
示例3: compareFrequencies
def compareFrequencies():
times = generateTimes(sampleFreq, numSamples)
signal = (80.0, 0.1)
coherent = (60.0, 1.0)
incoherent = (60.1, 1.0)
highFNoise = (500.0, 0.01)
timeData = generateTimeDomain(times, [signal, coherent, highFNoise])
timeData2 = generateTimeDomain(times, [signal, incoherent, highFNoise])
#timeData3 = generateTimeDomain(times, [signal, highFNoise])
#timeData = generateTimeDomain(times, [(60.0, 1.0)])
#timeData2 = generateTimeDomain(times, [(61.0, 1.0)])
roi = (0, 20)
freqData = map(toDb, map(dtype, map(absolute, fourier(timeData))))[roi[0]:roi[1]]
freqData2 = map(toDb, map(dtype, map(absolute, fourier(timeData2))))[roi[0]:roi[1]]
#freqData3 = map(toDb, map(dtype, map(absolute, fourier(timeData3))))[roi[0]:roi[1]]
frequencies = generateFFTFrequencies(sampleFreq, numSamples)[roi[0]:roi[1]]
#pylab.subplot(111)
pylab.plot(frequencies, freqData)
#pylab.subplot(112)
pylab.plot(frequencies, freqData2)
#pylab.plot(frequencies, freqData3)
pylab.grid(True)
pylab.show()
开发者ID:NickStupich,项目名称:PythonDFT-Analysis,代码行数:31,代码来源:v1.py
示例4: plot_BIC_score
def plot_BIC_score(BIC_SCORE, path):
xlabel('|C|')
ylabel('BIC score')
grid(True)
plot(BIC_SCORE)
savefig(os.path.join(path, 'BIC.png'))
close()
开发者ID:AndersHqst,项目名称:PyMTV,代码行数:7,代码来源:mtv_results.py
示例5: plot_running_time
def plot_running_time(running_time, path):
xlabel('|C|')
ylabel('MTV iteration in secs.')
grid(True)
plot([x for x in range(len(running_time))], running_time)
savefig(os.path.join(path, 'running_time.png'))
close()
开发者ID:AndersHqst,项目名称:PyMTV,代码行数:7,代码来源:mtv_results.py
示例6: plotter
def plotter(resfile):
# Import python matplotlib module
try:
import matplotlib.pylab as plt
except:
print >> sys.stderr, '\n Info: Python matplotlib module not found. Skipping plotting.'
return None
else:
# Open input result file
try:
ifile = open(resfile, 'r')
except:
print >> sys.stderr, 'Error: Not able to open result file ', resfile
sys.exit(-1)
# Read data from the input file
idata = ifile.readlines()
# Close the input file
try:
ifile.close()
except:
print >> sys.stderr, 'Warning: Not able to close input file ', resfile
# Read configuration file
parser = readConfig()
# Create and populate python lists
x, y = [], []
for value in idata:
if value[0] != '#':
try:
value.split()[2]
except IndexError:
pass
else:
x.append(value.split()[0])
y.append(value.split()[2])
# Set graph parameters and plot the completeness graph
graph = os.path.splitext(resfile)[0] + '.' + parser.get('plotter', 'save_format')
params = {'backend': 'ps',
'font.size': 10,
'axes.labelweight': 'medium',
'dpi' : 300,
'savefig.dpi': 300}
plt.rcParams.update(params)
fig = plt.figure()
plt.title(parser.get('plotter', 'title'), fontweight = 'bold', fontsize = 12)
plt.xlabel(parser.get('plotter', 'xlabel'))
plt.ylabel(parser.get('plotter', 'ylabel'))
plt.axis([float(min(x)) - 0.5, float(max(x)) + 0.5, 0.0, 110])
plt.grid(parser.get('plotter', 'grid'), linestyle = '-', color = '0.75')
plt.plot(x, y, parser.get('plotter', 'style'))
fig.savefig(graph)
return graph
开发者ID:navtejsingh,项目名称:mccomplete,代码行数:60,代码来源:complete_pp.py
示例7: plotFirstTacROC
def plotFirstTacROC(dataset):
import matplotlib.pylab as plt
from os.path import join
from src.utils import PROJECT_DIR
plt.figure(figsize=(6, 6))
time_sampler = TimeSerieSampler(n_time_points=12)
evaluator = Evaluator()
time_series_idx = 0
methods = {
"cross_correlation": "Cross corr. ",
"kendall": "Kendall ",
"symbol_mutual": "Symbol MI ",
"symbol_similarity": "Symbol sim.",
}
for method in methods:
print method
predictor = SingleSeriesPredictor(good_methods[method], time_sampler)
prediction = predictor.predictAllInstancesCombined(dataset, time_series_idx)
roc_auc, fpr, tpr = evaluator.evaluate(prediction)
plt.plot(fpr, tpr, label=methods[method] + " (auc = %0.3f)" % roc_auc)
plt.legend(loc="lower right")
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel("False Positive Rate")
plt.ylabel("True Positive Rate")
plt.grid()
plt.savefig(join(PROJECT_DIR, "output", "firstTACROC.pdf"))
开发者ID:gajduk,项目名称:network-inference-from-short-time-series-gajduk,代码行数:28,代码来源:evaluator.py
示例8: plot_degreeOverlap
def plot_degreeOverlap(db, keynames, save_path, attr_name = 'degOverlapRatio'):
plt.clf()
plt.figure(figsize = (8, 5))
x = sorted(db[keynames['mog']][attr_name].keys())
y = [db[keynames['mog']][attr_name][xx] for xx in x]
plt.plot(x, y, 'b-', lw = 5, label = 'fairyland interaction')
x = sorted(db[keynames['mblg']][attr_name].keys())
y = [db[keynames['mblg']][attr_name][xx] for xx in x]
plt.plot(x, y, 'r:', lw = 5, label = 'twitter interaction')
x = sorted(db[keynames['im']][attr_name].keys())
y = [db[keynames['im']][attr_name][xx] for xx in x]
plt.plot(x, y, 'k--', lw = 5, label = 'yahoo interaction')
x = sorted(db[keynames['mogF']][attr_name].keys())
y = [db[keynames['mogF']][attr_name][xx] for xx in x]
plt.plot(x, y, 'b.', label = 'fairyland ally')
x = sorted(db[keynames['mblgF']][attr_name].keys())
y = [db[keynames['mblgF']][attr_name][xx] for xx in x]
plt.plot(x, y, 'k*', label = 'twitter ally')
plt.grid(True)
plt.title('Overlap')
plt.xlabel('Fraction of Users ordered by degree (%)')
plt.ylabel('Overlap (%)')
plt.legend(('fairyland interaction', 'twitter interaction', 'yahoo interaction', 'fairyland ally', 'twitter ally'), loc = 'best')
plt.savefig(os.path.join(save_dir, save_path))
开发者ID:kaeaura,项目名称:churn_prediction_proj,代码行数:31,代码来源:paper_ploter.py
示例9: 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()
开发者ID:NickStupich,项目名称:PythonDFT-Analysis,代码行数:26,代码来源:fftDataExtraction.py
示例10: plotDist
def plotDist(subplot, X, Y, label):
pylab.grid()
pylab.subplot(subplot)
pylab.bar(X, Y, 0.05)
pylab.ylabel(label)
pylab.xticks(arange(len(X)), X)
pylab.yticks(arange(0,1,0.1))
开发者ID:malimome,项目名称:old-projects,代码行数:7,代码来源:infoSec.py
示例11: plot_degreeRate
def plot_degreeRate(db, keynames, save_path):
degRate_x_name = 'degRateDistr_x'
degRate_y_name = 'degRateDistr_y'
plt.clf()
plt.figure(figsize = (8, 5))
plt.subplot(1, 2, 1)
plt.plot(db[keynames['mog']][degRate_x_name], db[keynames['mog']][degRate_y_name], 'b-', lw=5, label = 'fairyland')
plt.plot(db[keynames['mblg']][degRate_x_name], db[keynames['mblg']][degRate_y_name], 'r:', lw=5, label = 'twitter')
plt.plot(db[keynames['im']][degRate_x_name], db[keynames['im']][degRate_y_name], 'k--', lw=5, label = 'yahoo')
plt.xscale('log')
plt.grid(True)
plt.title('interaction')
plt.legend(('fairyland', 'twitter', 'yahoo'), loc = 4, prop = {'size': 10})
plt.xlabel('In-degree to Out-degree Ratio')
plt.ylabel('CDF')
plt.subplot(1, 2, 2)
plt.plot(db[keynames['mogF']][degRate_x_name], db[keynames['mogF']][degRate_y_name], 'b-', lw=5, label = 'fairyland')
plt.plot(db[keynames['mblgF']][degRate_x_name], db[keynames['mblgF']][degRate_y_name], 'r:', lw=5, label = 'twitter')
#plt.plot(db[keynames['imF']][degRate_x_name], db[keynames['imF']][degRate_y_name], 'k--', lw=5, label = 'yahoo')
plt.xscale('log')
plt.grid(True)
plt.title('ally')
plt.xlabel('In-degree to Out-degree Ratio')
plt.ylabel('CDF')
plt.savefig(os.path.join(save_dir, save_path))
开发者ID:kaeaura,项目名称:churn_prediction_proj,代码行数:29,代码来源:paper_ploter.py
示例12: validate
def validate(X_test, y_test, pipe, title, fileName):
print('Test Accuracy: %.3f' % pipe.score(X_test, y_test))
y_predict = pipe.predict(X_test)
confusion_matrix = np.zeros((9,9))
for p,r in zip(y_predict, y_test):
confusion_matrix[p-1,r-1] = confusion_matrix[p-1,r-1] + 1
print (confusion_matrix)
confusion_normalized = confusion_matrix.astype('float') / confusion_matrix.sum(axis=1)[:, np.newaxis]
print (confusion_normalized)
pylab.clf()
pylab.matshow(confusion_normalized, fignum=False, cmap='Blues', vmin=0.0, vmax=1.0)
ax = pylab.axes()
ax.set_xticks(range(len(families)))
ax.set_xticklabels(families, fontsize=4)
ax.xaxis.set_label_position('top')
ax.xaxis.set_ticks_position("top")
ax.set_yticks(range(len(families)))
ax.set_yticklabels(families, fontsize=4)
pylab.title(title)
pylab.colorbar()
pylab.grid(False)
pylab.grid(False)
pylab.savefig(fileName, dpi=900)
开发者ID:tlabruyere,项目名称:CS544-Cyber,代码行数:30,代码来源:kNeighbor.py
示例13: 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")
开发者ID:Xelaju,项目名称:NumMeth,代码行数:28,代码来源:interp.py
示例14: unteraufgabe_c
def unteraufgabe_c():
f = lambda x: np.sin(10*x*np.cos(x))
[A10,A20] = unteraufgabe_b()
b10 = np.zeros_like(x10)
b20 = np.zeros_like(x20)
alpha10 = np.zeros_like(x10)
alpha20 = np.zeros_like(x20)
b10 = f(x10)
b20 = f(x20)
alpha10 = solve(A10,b10)
alpha20 = solve(A20,b20)
x = np.linspace(0.0, 1.0, 100)
pi10 = np.zeros_like(x)
pi20 = np.zeros_like(x)
pi10 = np.polyval(alpha10,x)
pi20 = np.polyval(alpha20,x)
plt.figure()
plt.plot(x,f(x),"-b",label=r"$f(x)$")
plt.plot(x,pi10 ,"-g",label=r"$p_{10}(x)$")
plt.plot(x10,b10,"dg")
plt.plot(x,pi20 ,"-r",label=r"$p_{20}(x)$")
plt.plot(x20,b20,"or")
plt.grid(True)
plt.xlabel(r"$x$")
plt.ylabel(r"$y$")
plt.legend()
plt.savefig("interpolation.eps")
开发者ID:Xelaju,项目名称:NumMeth,代码行数:32,代码来源:interp.py
示例15: plotRocCurves
def plotRocCurves(file_legend):
pylab.clf()
pylab.figure(1)
pylab.xlabel('1 - Specificity', fontsize=12)
pylab.ylabel('Sensitivity', fontsize=12)
pylab.title("Need for Referral")
pylab.grid(True, which='both')
pylab.xticks([i/10.0 for i in range(1,11)])
pylab.yticks([i/10.0 for i in range(0,11)])
pylab.tick_params(axis="both", labelsize=15)
for file, legend in file_legend:
points = open(file,"rb").readlines()
x = [float(p.split()[0]) for p in points]
y = [float(p.split()[1]) for p in points]
dev = [float(p.split()[2]) for p in points]
x = [0.0] + x
y = [0.0] + y
dev = [0.0] + dev
auc = np.trapz(y, x) * 100
aucDev = np.trapz(dev, x) * 100
pylab.grid()
pylab.errorbar(x, y, yerr = dev, fmt='-')
pylab.plot(x, y, '-', linewidth = 1.5, label = legend + u" (AUC = {0:0.1f}% \xb1 {1:0.1f}%)".format(auc,aucDev))
pylab.legend(loc = 4, borderaxespad=0.4, prop={'size':12})
pylab.savefig("referral/referral-curves.pdf", format='pdf')
开发者ID:piresramon,项目名称:retina.bovw.plosone,代码行数:29,代码来源:referral.py
示例16: plot_fullstack
def plot_fullstack( binning = np.linspace(0,10,1), myquery='', plotvar = default_plot_variable, \
scalefactor = 1., user_ylim = None):
fig = plt.figure(figsize=(10,6))
plt.grid(True)
lasthist = 0
myhistos = gen_histos(binning=binning,myquery=myquery,plotvar=plotvar,scalefactor=scalefactor)
for key, (hist, bins) in myhistos.iteritems():
plt.bar(bins[:-1],hist,
width=bins[1]-bins[0],
color=colors[key],
bottom = lasthist,
edgecolor = 'k',
label='%s: %d Events'%(labels[key],sum(hist)))
lasthist += hist
plt.title('CCSingleE Stacked Backgrounds',fontsize=25)
plt.ylabel('Events',fontsize=20)
if plotvar == '_e_nuReco' or plotvar == '_e_nuReco_better':
xstring = 'Reconstructed Neutrino Energy [GeV]'
elif plotvar == '_e_CCQE':
xstring = 'CCQE Energy [GeV]'
else:
xstring = plotvar
plt.xlabel(xstring,fontsize=20)
plt.legend()
plt.xticks(list(plt.xticks()[0]) + [binning[0]])
plt.xlim([binning[0],binning[-1]])
开发者ID:kaleko,项目名称:LowEnergyExcess,代码行数:30,代码来源:stack_plotter.py
示例17: _on_button_press
def _on_button_press(event):
if event.button != 1 or not event.inaxes:
return
lon, lat = m(event.xdata, event.ydata, inverse=True)
# Convert to colat to ease indexing.
colat = rotations.lat2colat(lat)
x_range = (self.setup["physical_boundaries_x"][1] -
self.setup["physical_boundaries_x"][0])
x_frac = (colat - self.setup["physical_boundaries_x"][0]) / x_range
x_index = int(((self.setup["boundaries_x"][1] -
self.setup["boundaries_x"][0]) * x_frac) +
self.setup["boundaries_x"][0])
y_range = (self.setup["physical_boundaries_y"][1] -
self.setup["physical_boundaries_y"][0])
y_frac = (lon - self.setup["physical_boundaries_y"][0]) / y_range
y_index = int(((self.setup["boundaries_y"][1] -
self.setup["boundaries_y"][0]) * y_frac) +
self.setup["boundaries_y"][0])
plt.figure(1, figsize=(3, 8))
depths = available_depths
values = data[x_index, y_index, :]
plt.plot(values, depths)
plt.grid()
plt.ylim(depths[-1], depths[0])
plt.show()
plt.close()
plt.figure(0)
开发者ID:msimon00,项目名称:LASIF,代码行数:29,代码来源:ses3d_models.py
示例18: Time
def Time(self): # ,dimension): # Dimension is unit type as V(olt) W(att), etc
plt.plot(self.signalx, self.signaly)
plt.xlabel('time [s]') # or sample number
plt.ylabel('voltage [mV]') # auto add unit here
plt.title(' ')
plt.grid(True)
plt.show()
开发者ID:Jee-Bee,项目名称:Meas,代码行数:7,代码来源:defaultfigures.py
示例19: plot
def plot(W, idx2term):
"""
Plot the interpretation of NMF basis vectors on Medlars data set.
:param W: Basis matrix of the fitted factorization model.
:type W: `scipy.sparse.csr_matrix`
:param idx2term: Index-to-term translator.
:type idx2term: `dict`
"""
print "Plotting highest weighted terms in basis vectors ..."
for c in xrange(W.shape[1]):
if sp.isspmatrix(W):
top10 = sorted(enumerate(W[:, c].todense().ravel().tolist()[0]), key = itemgetter(1), reverse = True)[:10]
else:
top10 = sorted(enumerate(W[:, c].ravel().tolist()[0]), key = itemgetter(1), reverse = True)[:10]
pos = np.arange(10) + .5
val = zip(*top10)[1][::-1]
plb.figure(c + 1)
plb.barh(pos, val, color = "yellow", align = "center")
plb.yticks(pos, [idx2term[idx] for idx in zip(*top10)[0]][::-1])
plb.xlabel("Weight")
plb.ylabel("Term")
plb.title("Highest Weighted Terms in Basis Vector W%d" % (c + 1))
plb.grid(True)
plb.savefig("documents_basisW%d.png" % (c + 1), bbox_inches = "tight")
print "... Finished."
开发者ID:SkyTodInfi,项目名称:MF,代码行数:26,代码来源:documents.py
示例20: SpecMag
def SpecMag(self): # ,dimension): # Dimension is unit type as V(olt) W(att), etc
plt.plot(self.signalx, self.signaly)
plt.xlabel('frequency [Hz]') # or frequency bin
plt.ylabel('voltage [mV]') # auto add unit here
plt.title(' ') # set title
plt.grid(True)
plt.show()
开发者ID:Jee-Bee,项目名称:Meas,代码行数:7,代码来源:defaultfigures.py
注:本文中的matplotlib.pylab.grid函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论