本文整理汇总了Python中matplotlib.pylab.xlabel方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.xlabel方法的具体用法?Python pylab.xlabel怎么用?Python pylab.xlabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.xlabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_clustering
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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_entropy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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
示例3: plot_roc
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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
示例4: plot_fermi_dirac
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def plot_fermi_dirac(self):
"""
Plots the obtained eigenvalue vs occupation plot
"""
try:
import matplotlib.pylab as plt
except ModuleNotFoundError:
import matplotlib.pyplot as plt
arg = np.argsort(self.eigenvalues)
plt.plot(
self.eigenvalues[arg], self.occupancies[arg], linewidth=2.0, color="blue"
)
plt.axvline(self.efermi, linewidth=2.0, linestyle="dashed", color="black")
plt.xlabel("Energies (eV)")
plt.ylabel("Occupancy")
return plt
示例5: plot_equilibration
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def plot_equilibration(temperature_next, strain_lst, nve_run_time_steps, project_parameter, debug_plot=True):
if debug_plot:
for strain in strain_lst:
job_name = get_nve_job_name(
temperature_next=temperature_next,
strain=strain,
steps_lst=project_parameter['nve_run_time_steps_lst'],
nve_run_time_steps=nve_run_time_steps
)
ham_nve = project_parameter['project'].load(job_name)
plt.plot(ham_nve['output/generic/temperature'], label='strain: ' + str(strain))
plt.axhline(np.mean(ham_nve['output/generic/temperature'][-20:]), linestyle='--', color='red')
plt.axvline(range(len(ham_nve['output/generic/temperature']))[-20], linestyle='--', color='black')
plt.legend()
plt.xlabel('timestep')
plt.ylabel('Temperature K')
plt.legend()
plt.show()
示例6: check_for_holes
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def check_for_holes(temperature_next, strain_value_lst, nve_run_time_steps, project_parameter, debug_plot=True):
max_lst, mean_lst = get_voronoi_volume(
temperature_next=temperature_next,
strain_lst=strain_value_lst,
nve_run_time_steps=nve_run_time_steps,
project_parameter=project_parameter
)
if debug_plot:
plt.plot(strain_value_lst, mean_lst, label='mean')
plt.plot(strain_value_lst, max_lst, label='max')
plt.axhline(np.mean(mean_lst) * 2, color='black', linestyle='--')
plt.legend()
plt.xlabel('Strain')
plt.ylabel('Voronoi Volume')
plt.show()
return np.array(max_lst) < np.mean(mean_lst) * 2
示例7: plot_efrontier
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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()
示例8: plot_pr
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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
示例9: plot_pr_curve
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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()
示例10: plotKChart
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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 ########################################
# 例子
示例11: plot_alignment_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def plot_alignment_to_numpy(alignment, info=None):
fig, ax = plt.subplots(figsize=(6, 4))
im = ax.imshow(alignment, aspect='auto', origin='lower',
interpolation='none')
fig.colorbar(im, ax=ax)
xlabel = 'Decoder timestep'
if info is not None:
xlabel += '\n\n' + info
plt.xlabel(xlabel)
plt.ylabel('Encoder timestep')
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data
示例12: addqqplotinfo
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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()
示例13: viz_missing_docwordfreq_stats
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def viz_missing_docwordfreq_stats(DocWordFreq_emp, DocWordFreq_model):
from matplotlib import pylab
DocWordFreq_missing = np.maximum(DocWordFreq_emp - DocWordFreq_model, 0)
nnzEmp = count_num_nonzero(DocWordFreq_emp)
nnzMiss = count_num_nonzero(DocWordFreq_missing)
frac_nzMiss = nnzMiss / float(nnzEmp)
nzMissPerDoc = np.sum(DocWordFreq_missing > 0, axis=1)
CDF_nzMissPerDoc = np.sort(nzMissPerDoc)
nzMissPerWord = np.sum(DocWordFreq_missing > 0, axis=0)
CDF_nzMissPerWord = np.sort(nzMissPerWord)
pylab.subplot(1,2,1)
pylab.plot(CDF_nzMissPerDoc)
pylab.ylabel('Num Nonzero Entries in Doc')
pylab.xlabel('Document rank | frac= %.4f'% (frac_nzMiss))
pylab.subplot(1,2,2)
pylab.plot(CDF_nzMissPerWord)
pylab.ylabel('Num Nonzero Entries per Word')
pylab.xlabel('Word rank')
pylab.show(block=True)
示例14: plot_performance_profiles
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [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)
示例15: plot_gate_outputs_to_numpy
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import xlabel [as 别名]
def plot_gate_outputs_to_numpy(gate_targets, gate_outputs):
fig, ax = plt.subplots(figsize=(12, 3))
ax.scatter(
range(len(gate_targets)), gate_targets, alpha=0.5, color='green', marker='+', s=1, label='target',
)
ax.scatter(
range(len(gate_outputs)), gate_outputs, alpha=0.5, color='red', marker='.', s=1, label='predicted',
)
plt.xlabel("Frames (Green target, Red predicted)")
plt.ylabel("Gate State")
plt.tight_layout()
fig.canvas.draw()
data = save_figure_to_numpy(fig)
plt.close()
return data