本文整理汇总了Python中matplotlib.pylab.ylim方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.ylim方法的具体用法?Python pylab.ylim怎么用?Python pylab.ylim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.ylim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_clustering
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [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
示例2: plot_roc
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [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
示例3: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [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
示例4: plot_pr_curve
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [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()
示例5: plot_xz_landscape
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_xz_landscape(self):
"""
plots the xz landscape, i.e., how your vna frequency span changes with respect to the x vector
:return: None
"""
if not qkit.module_available("matplotlib"):
raise ImportError("matplotlib not found.")
if self.xzlandscape_func:
y_values = self.xzlandscape_func(self.spec.x_vec)
plt.plot(self.spec.x_vec, y_values, 'C1')
plt.fill_between(self.spec.x_vec, y_values+self.z_span/2., y_values-self.z_span/2., color='C0', alpha=0.5)
plt.xlim((self.spec.x_vec[0], self.spec.x_vec[-1]))
plt.ylim((self.xz_freqpoints[0], self.xz_freqpoints[-1]))
plt.show()
else:
print('No xz funcion generated. Use landscape.generate_xz_function')
示例6: addqqplotinfo
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def addqqplotinfo(qnull,M,xl='-log10(P) observed',yl='-log10(P) expected',xlim=None,ylim=None,alphalevel=0.05,legendlist=None,fixaxes=False):
distr='log10'
pl.plot([0,qnull.max()], [0,qnull.max()],'k')
pl.ylabel(xl)
pl.xlabel(yl)
if xlim is not None:
pl.xlim(xlim)
if ylim is not None:
pl.ylim(ylim)
if alphalevel is not None:
if distr == 'log10':
betaUp, betaDown, theoreticalPvals = _qqplot_bar(M=M,alphalevel=alphalevel,distr=distr)
lower = -sp.log10(theoreticalPvals-betaDown)
upper = -sp.log10(theoreticalPvals+betaUp)
pl.fill_between(-sp.log10(theoreticalPvals),lower,upper,color="grey",alpha=0.5)
#pl.plot(-sp.log10(theoreticalPvals),lower,'g-.')
#pl.plot(-sp.log10(theoreticalPvals),upper,'g-.')
if legendlist is not None:
leg = pl.legend(legendlist, loc=4, numpoints=1)
# set the markersize for the legend
for lo in leg.legendHandles:
lo.set_markersize(10)
if fixaxes:
fix_axes()
示例7: plot_performance_profiles
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_performance_profiles(problems, solvers):
"""
Plot performance profiles in matplotlib for specified problems and solvers
"""
# Remove OSQP polish solver
solvers = solvers.copy()
for s in solvers:
if "polish" in s:
solvers.remove(s)
df = pd.read_csv('./results/%s/performance_profiles.csv' % problems)
plt.figure(0)
for solver in solvers:
plt.plot(df["tau"], df[solver], label=solver)
plt.xlim(1., 10000.)
plt.ylim(0., 1.)
plt.xlabel(r'Performance ratio $\tau$')
plt.ylabel('Ratio of problems solved')
plt.xscale('log')
plt.legend()
plt.grid()
plt.show(block=False)
results_file = './results/%s/%s.png' % (problems, problems)
print("Saving plots to %s" % results_file)
plt.savefig(results_file)
示例8: dispersion_plot
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def dispersion_plot(text, words, ignore_case=False, title="Lexical Dispersion Plot"):
"""
Generate a lexical dispersion plot.
:param text: The source text
:type text: list(str) or enum(str)
:param words: The target words
:type words: list of str
:param ignore_case: flag to set if case should be ignored when searching text
:type ignore_case: bool
"""
try:
from matplotlib import pylab
except ImportError:
raise ValueError('The plot function requires matplotlib to be installed.'
'See http://matplotlib.org/')
text = list(text)
words.reverse()
if ignore_case:
words_to_comp = list(map(str.lower, words))
text_to_comp = list(map(str.lower, text))
else:
words_to_comp = words
text_to_comp = text
points = [(x,y) for x in range(len(text_to_comp))
for y in range(len(words_to_comp))
if text_to_comp[x] == words_to_comp[y]]
if points:
x, y = list(zip(*points))
else:
x = y = ()
pylab.plot(x, y, "b|", scalex=.1)
pylab.yticks(list(range(len(words))), words, color="b")
pylab.ylim(-1, len(words))
pylab.title(title)
pylab.xlabel("Word Offset")
pylab.show()
示例9: plot_valdata
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_valdata(x_val_cuda, knobs_val_cuda, y_val_cuda, y_val_hat_cuda, effect, \
epoch, loss_val, file_prefix='val_data', num_plots=50, target_size=None):
x_size = len(x_val_cuda.data.cpu().numpy()[0])
if target_size is None:
y_size = len(y_val_cuda.data.cpu().numpy()[0])
else:
y_size = target_size
t_small = range(x_size-y_size, x_size)
for plot_i in range(0, num_plots):
x_val = x_val_cuda.data.cpu().numpy()
knobs_w = effect.knobs_wc( knobs_val_cuda.data.cpu().numpy()[plot_i,:] )
plt.figure(plot_i,figsize=(6,8))
titlestr = f'{effect.name} Val data, epoch {epoch+1}, loss_val = {loss_val.item():.3e}\n'
for i in range(len(effect.knob_names)):
titlestr += f'{effect.knob_names[i]} = {knobs_w[i]:.2f}'
if i < len(effect.knob_names)-1: titlestr += ', '
plt.suptitle(titlestr)
plt.subplot(3, 1, 1)
plt.plot(x_val[plot_i, :], 'b', label='Input')
plt.ylim(-1,1)
plt.xlim(0,x_size)
plt.legend()
plt.subplot(3, 1, 2)
y_val = y_val_cuda.data.cpu().numpy()
plt.plot(t_small, y_val[plot_i, -y_size:], 'r', label='Target')
plt.xlim(0,x_size)
plt.ylim(-1,1)
plt.legend()
plt.subplot(3, 1, 3)
plt.plot(t_small, y_val[plot_i, -y_size:], 'r', label='Target')
y_val_hat = y_val_hat_cuda.data.cpu().numpy()
plt.plot(t_small, y_val_hat[plot_i, -y_size:], c=(0,0.5,0,0.85), label='Predicted')
plt.ylim(-1,1)
plt.xlim(0,x_size)
plt.legend()
filename = file_prefix + '_' + str(plot_i) + '.png'
savefig(filename)
return
示例10: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_pr(auc_score, name, phase, precision, recall, label=None):
pylab.clf()
pylab.figure(num=None, figsize=(5, 4))
pylab.grid(True)
pylab.fill_between(recall, precision, alpha=0.5)
pylab.plot(recall, precision, lw=1)
pylab.xlim([0.0, 1.0])
pylab.ylim([0.0, 1.0])
pylab.xlabel('Recall')
pylab.ylabel('Precision')
pylab.title('P/R curve (AUC=%0.2f) / %s' % (auc_score, label))
filename = name.replace(" ", "_")
pylab.savefig(os.path.join(CHART_DIR, "pr_%s_%s.png" %
(filename, phase)), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:16,代码来源:utils.py
示例11: plot_bias_variance
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_bias_variance(data_sizes, train_errors, test_errors, name):
pylab.clf()
pylab.ylim([0.0, 1.0])
pylab.xlabel('Data set size')
pylab.ylabel('Error')
pylab.title("Bias-Variance for '%s'" % name)
pylab.plot(
data_sizes, train_errors, "-", data_sizes, test_errors, "--", lw=1)
pylab.legend(["train error", "test error"], loc="upper right")
pylab.grid()
pylab.savefig(os.path.join(CHART_DIR, "bv_" + name + ".png"))
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:13,代码来源:utils.py
示例12: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_pr(auc_score, name, precision, recall, label=None):
pylab.clf()
pylab.figure(num=None, figsize=(5, 4))
pylab.grid(True)
pylab.fill_between(recall, precision, alpha=0.5)
pylab.plot(recall, precision, lw=1)
pylab.xlim([0.0, 1.0])
pylab.ylim([0.0, 1.0])
pylab.xlabel('Recall')
pylab.ylabel('Precision')
pylab.title('P/R curve (AUC = %0.2f) / %s' % (auc_score, label))
filename = name.replace(" ", "_")
pylab.savefig(
os.path.join(CHART_DIR, "pr_" + filename + ".png"), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:16,代码来源:utils.py
示例13: plot_roc
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_roc(auc_score, name, fpr, tpr):
pylab.figure(num=None, figsize=(6, 5))
pylab.plot([0, 1], [0, 1], 'k--')
pylab.xlim([0.0, 1.0])
pylab.ylim([0.0, 1.0])
pylab.xlabel('False Positive Rate')
pylab.ylabel('True Positive Rate')
pylab.title('Receiver operating characteristic (AUC=%0.2f)\n%s' % (
auc_score, name))
pylab.legend(loc="lower right")
pylab.grid(True, linestyle='-', color='0.75')
pylab.fill_between(tpr, fpr, alpha=0.5)
pylab.plot(fpr, tpr, lw=1)
pylab.savefig(
os.path.join(CHART_DIR, "roc_" + name.replace(" ", "_") + ".png"))
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:17,代码来源:utils.py
示例14: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_pr(auc_score, name, precision, recall, label=None):
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)
filename = name.replace(" ", "_")
pylab.savefig(os.path.join(CHART_DIR, "pr_" + filename + ".png"))
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:14,代码来源:utils.py
示例15: plot_bias_variance
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ylim [as 别名]
def plot_bias_variance(data_sizes, train_errors, test_errors, name, title):
pylab.figure(num=None, figsize=(6, 5))
pylab.ylim([0.0, 1.0])
pylab.xlabel('Data set size')
pylab.ylabel('Error')
pylab.title("Bias-Variance for '%s'" % name)
pylab.plot(
data_sizes, test_errors, "--", data_sizes, train_errors, "b-", lw=1)
pylab.legend(["test error", "train error"], loc="upper right")
pylab.grid(True, linestyle='-', color='0.75')
pylab.savefig(
os.path.join(CHART_DIR, "bv_" + name.replace(" ", "_") + ".png"), bbox_inches="tight")
开发者ID:PacktPublishing,项目名称:Building-Machine-Learning-Systems-With-Python-Second-Edition,代码行数:14,代码来源:utils.py