本文整理汇总了Python中matplotlib.pylab.grid函数的典型用法代码示例。如果您正苦于以下问题:Python grid函数的具体用法?Python grid怎么用?Python grid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了grid函数的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: 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")
示例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()
示例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()
示例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()
示例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
示例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"))
示例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))
示例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()
示例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))
示例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))
示例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)
示例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")
示例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")
示例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')