本文整理汇总了Python中matplotlib.pylab.title方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.title方法的具体用法?Python pylab.title怎么用?Python pylab.title使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.title方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: error_bar_plot
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def error_bar_plot(experiment_data, results, title="", ylabel=""):
true_effect = experiment_data.true_effects.mean()
estimators = list(results.keys())
x = list(estimators)
y = [results[estimator].ate for estimator in estimators]
cis = [
np.array(results[estimator].ci) - results[estimator].ate
if results[estimator].ci is not None
else [0, 0]
for estimator in estimators
]
err = [[abs(ci[0]) for ci in cis], [abs(ci[1]) for ci in cis]]
plt.figure(figsize=(12, 5))
(_, caps, _) = plt.errorbar(x, y, yerr=err, fmt="o", markersize=8, capsize=5)
for cap in caps:
cap.set_markeredgewidth(2)
plt.plot(x, [true_effect] * len(x), label="True Effect")
plt.legend(fontsize=12, loc="lower right")
plt.ylabel(ylabel)
plt.title(title)
示例2: plotallfuncs
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plotallfuncs(allfuncs=allfuncs):
from matplotlib import pylab as pl
pl.ioff()
nnt = NNTester(npoints=1000)
lpt = LinearTester(npoints=1000)
for func in allfuncs:
print(func.title)
nnt.plot(func, interp=False, plotter='imshow')
pl.savefig('%s-ref-img.png' % func.func_name)
nnt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-nn-img.png' % func.func_name)
lpt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-lin-img.png' % func.func_name)
nnt.plot(func, interp=False, plotter='contour')
pl.savefig('%s-ref-con.png' % func.func_name)
nnt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-nn-con.png' % func.func_name)
lpt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-lin-con.png' % func.func_name)
pl.ion()
示例3: plot_clustering
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_clustering(x, y, title, mx=None, ymax=None, xmin=None, km=None):
pylab.figure(num=None, figsize=(8, 6))
if km:
pylab.scatter(x, y, s=50, c=km.predict(list(zip(x, y))))
else:
pylab.scatter(x, y, s=50)
pylab.title(title)
pylab.xlabel("Occurrence word 1")
pylab.ylabel("Occurrence word 2")
pylab.autoscale(tight=True)
pylab.ylim(ymin=0, ymax=1)
pylab.xlim(xmin=0, xmax=1)
pylab.grid(True, linestyle='-', color='0.75')
return pylab
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:plot_kmeans_example.py
示例4: plot_feat_importance
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_feat_importance(feature_names, clf, name):
pylab.clf()
coef_ = clf.coef_
important = np.argsort(np.absolute(coef_.ravel()))
f_imp = feature_names[important]
coef = coef_.ravel()[important]
inds = np.argsort(coef)
f_imp = f_imp[inds]
coef = coef[inds]
xpos = np.array(range(len(coef)))
pylab.bar(xpos, coef, width=1)
pylab.title('Feature importance for %s' % (name))
ax = pylab.gca()
ax.set_xticks(np.arange(len(coef)))
labels = ax.set_xticklabels(f_imp)
for label in labels:
label.set_rotation(90)
filename = name.replace(" ", "_")
pylab.savefig(os.path.join(
CHART_DIR, "feat_imp_%s.png" % filename), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:23,代码来源:utils.py
示例5: plot_entropy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_entropy():
pylab.clf()
pylab.figure(num=None, figsize=(5, 4))
title = "Entropy $H(X)$"
pylab.title(title)
pylab.xlabel("$P(X=$coin will show heads up$)$")
pylab.ylabel("$H(X)$")
pylab.xlim(xmin=0, xmax=1.1)
x = np.arange(0.001, 1, 0.001)
y = -x * np.log2(x) - (1 - x) * np.log2(1 - x)
pylab.plot(x, y)
# pylab.xticks([w*7*24 for w in [0,1,2,3,4]], ['week %i'%(w+1) for w in
# [0,1,2,3,4]])
pylab.autoscale(tight=True)
pylab.grid(True)
filename = "entropy_demo.png"
pylab.savefig(os.path.join(CHART_DIR, filename), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:23,代码来源:demo_mi.py
示例6: plot_confusion_matrix
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_confusion_matrix(cm, genre_list, name, title):
pylab.clf()
pylab.matshow(cm, fignum=False, cmap='Blues', vmin=0, vmax=1.0)
ax = pylab.axes()
ax.set_xticks(range(len(genre_list)))
ax.set_xticklabels(genre_list)
ax.xaxis.set_ticks_position("bottom")
ax.set_yticks(range(len(genre_list)))
ax.set_yticklabels(genre_list)
pylab.title(title)
pylab.colorbar()
pylab.grid(False)
pylab.show()
pylab.xlabel('Predicted class')
pylab.ylabel('True class')
pylab.grid(False)
pylab.savefig(
os.path.join(CHART_DIR, "confusion_matrix_%s.png" % name), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:20,代码来源:utils.py
示例7: plot_roc
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_roc(auc_score, name, tpr, fpr, label=None):
pylab.clf()
pylab.figure(num=None, figsize=(5, 4))
pylab.grid(True)
pylab.plot([0, 1], [0, 1], 'k--')
pylab.plot(fpr, tpr)
pylab.fill_between(fpr, tpr, alpha=0.5)
pylab.xlim([0.0, 1.0])
pylab.ylim([0.0, 1.0])
pylab.xlabel('False Positive Rate')
pylab.ylabel('True Positive Rate')
pylab.title('ROC curve (AUC = %0.2f) / %s' %
(auc_score, label), verticalalignment="bottom")
pylab.legend(loc="lower right")
filename = name.replace(" ", "_")
pylab.savefig(
os.path.join(CHART_DIR, "roc_" + filename + ".png"), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:19,代码来源:utils.py
示例8: plotallfuncs
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plotallfuncs(allfuncs=allfuncs):
from matplotlib import pylab as pl
pl.ioff()
nnt = NNTester(npoints=1000)
lpt = LinearTester(npoints=1000)
for func in allfuncs:
print(func.title)
nnt.plot(func, interp=False, plotter='imshow')
pl.savefig('%s-ref-img.png' % func.__name__)
nnt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-nn-img.png' % func.__name__)
lpt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-lin-img.png' % func.__name__)
nnt.plot(func, interp=False, plotter='contour')
pl.savefig('%s-ref-con.png' % func.__name__)
nnt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-nn-con.png' % func.__name__)
lpt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-lin-con.png' % func.__name__)
pl.ion()
示例9: plot_efrontier
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_efrontier(self):
"""Plots the Efficient Frontier."""
if self.efrontier is None:
# compute efficient frontier first
self.efficient_frontier()
plt.plot(
self.efrontier[:, 0],
self.efrontier[:, 1],
linestyle="-.",
color="black",
lw=2,
label="Efficient Frontier",
)
plt.title("Efficient Frontier")
plt.xlabel("Volatility")
plt.ylabel("Expected Return")
plt.legend()
示例10: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_pr(auc_score, precision, recall, label=None, figure_path=None):
"""绘制R/P曲线"""
try:
from matplotlib import pylab
pylab.figure(num=None, figsize=(6, 5))
pylab.xlim([0.0, 1.0])
pylab.ylim([0.0, 1.0])
pylab.xlabel('Recall')
pylab.ylabel('Precision')
pylab.title('P/R (AUC=%0.2f) / %s' % (auc_score, label))
pylab.fill_between(recall, precision, alpha=0.5)
pylab.grid(True, linestyle='-', color='0.75')
pylab.plot(recall, precision, lw=1)
pylab.savefig(figure_path)
except Exception as e:
print("save image error with matplotlib")
pass
示例11: plot_pr_curve
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plot_pr_curve(pr_curve_dml, pr_curve_base, title):
"""
Function that plots the PR-curve.
Args:
pr_curve: the values of precision for each recall value
title: the title of the plot
"""
plt.figure(figsize=(16, 9))
plt.plot(np.arange(0.0, 1.05, 0.05),
pr_curve_base, color='r', marker='o', linewidth=3, markersize=10)
plt.plot(np.arange(0.0, 1.05, 0.05),
pr_curve_dml, color='b', marker='o', linewidth=3, markersize=10)
plt.grid(True, linestyle='dotted')
plt.xlabel('Recall', color='k', fontsize=27)
plt.ylabel('Precision', color='k', fontsize=27)
plt.yticks(color='k', fontsize=20)
plt.xticks(color='k', fontsize=20)
plt.ylim([0.0, 1.05])
plt.xlim([0.0, 1.0])
plt.title(title, color='k', fontsize=27)
plt.tight_layout()
plt.show()
示例12: plotKChart
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def plotKChart(self, misClassDict, saveFigPath):
kList = []
misRateList = []
for k, misClassNum in misClassDict.iteritems():
kList.append(k)
misRateList.append(1.0 - 1.0/k*misClassNum)
fig = plt.figure(saveFigPath)
plt.plot(kList, misRateList, 'r--')
plt.title(saveFigPath)
plt.xlabel('k Num.')
plt.ylabel('Misclassified Rate')
plt.legend(saveFigPath)
plt.grid(True)
plt.savefig(saveFigPath)
plt.show()
################################### PART3 TEST ########################################
# 例子
示例13: show_pred
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def show_pred(images, predictions, ground_truth):
# choose 10 indice from images and visualize them
indice = [np.random.randint(0, len(images)) for i in range(40)]
for i in range(0, 40):
plt.figure()
plt.subplot(1, 3, 1)
plt.tight_layout()
plt.title('deformed image')
plt.imshow(images[indice[i]])
plt.subplot(1, 3, 2)
plt.tight_layout()
plt.title('predicted mask')
plt.imshow(predictions[indice[i]])
plt.subplot(1, 3, 3)
plt.tight_layout()
plt.title('ground truth label')
plt.imshow(ground_truth[indice[i]])
plt.show()
# Load Data Science Bowl 2018 training dataset
示例14: vPlotTrades
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def vPlotTrades(self, subset=None):
if subset is None:
subset = slice(None, None)
fr = self.trades.ix[subset]
le = fr.price[(fr.pos > 0) & (fr.vol > 0)]
se = fr.price[(fr.pos < 0) & (fr.vol < 0)]
lx = fr.price[(fr.pos.shift() > 0) & (fr.vol < 0)]
sx = fr.price[(fr.pos.shift() < 0) & (fr.vol > 0)]
import matplotlib.pylab as pylab
pylab.plot(le.index, le.values, '^', color='lime', markersize=12,
label='long enter')
pylab.plot(se.index, se.values, 'v', color='red', markersize=12,
label='short enter')
pylab.plot(lx.index, lx.values, 'o', color='lime', markersize=7,
label='long exit')
pylab.plot(sx.index, sx.values, 'o', color='red', markersize=7,
label='short exit')
eq = self.equity.ix[subset].cumsum()
ix = eq.index
oOS = getattr(self.ohlc, self.open_label)
(eq + oOS[ix[0]]).plot(color='red', style='-', label='strategy')
# self.ohlc.O.ix[ix[0]:ix[-1]].plot(color='black', label='price')
oOS.ix[subset].plot(color='black', label='price')
pylab.legend(loc='best')
pylab.title('%s\nTrades for %s' % (self, subset))
示例15: vPlotEquity
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import title [as 别名]
def vPlotEquity(rEquityDiff, mOhlc, sPeriod='W',
subset=None,
sTitle="Equity",
close_label='C',
):
if subset is None:
subset = slice(None, None)
else:
assert isinstance(subset, slice)
rEquitySum = rEquityDiff[subset].cumsum()
rEquitySum.plot(color='red', label='strategy')
ix = mOhlc.ix[rEquitySum.index[0]:rEquitySum.index[-1]].index
price = getattr(mOhlc, close_label)
(price[ix] - price[ix][0]).resample(sPeriod, how='first').dropna() \
.plot(color='black', alpha=0.5, label='underlying')
import matplotlib.pylab as pylab
pylab.legend(loc='best')
pylab.title(sTitle)
# pylint: disable=W0110,C0103,R0903,E1136,E1101
# C0103 invalid-name 39,54,66,179,180,180,182,214,216,217,273,284,285,286,287,288,300,301,321
# E1101 no-member 179,214,215,218,284,300
# E1136 unsubscriptable-object 181,182
# R0903 too-few-public-methods 28
# W0110 deprecated-lambda 61
# the end