本文整理汇总了Python中matplotlib.pyplot.semilogy方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.semilogy方法的具体用法?Python pyplot.semilogy怎么用?Python pyplot.semilogy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.semilogy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawXYPlotByFactor
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def drawXYPlotByFactor(dataDict, xlabel='', ylabel='', legend=None,
title=None, logy=False, location=5):
# Assuming that the data is in the format { factor: [(x1, y1),(x2,y2),...] }
PLOT_STYLES = ['r^-', 'bo-', 'g^-', 'ks-', 'ms-', 'co-', 'y^-']
styleCount = 0
displayedPlots = []
pltfn = plt.semilogy if logy else plt.plot
for factor in dataDict:
xpoints = [a[0] for a in dataDict[factor]]
ypoints = [a[1] for a in dataDict[factor]]
displayedPlots.append(pltfn(xpoints, ypoints, PLOT_STYLES[styleCount]))
styleCount = min(styleCount+1, len(PLOT_STYLES)-1)
plt.xlabel(xlabel)
plt.ylabel(ylabel)
if legend is None:
plt.legend(dataDict.keys(), loc=location)
else:
plt.legend(legend, loc=location)
if title is not None:
plt.title(title)
plt.show()
示例2: plot_beta
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot_beta():
'''plot beta over training
'''
beta = args.beta
scale = args.scale
beta_min = args.beta_min
num_epoch = args.num_epoch
epoch_size = int(float(args.num_examples) / args.batch_size)
x = np.arange(num_epoch*epoch_size)
y = beta * np.power(scale, x)
y = np.maximum(y, beta_min)
epoch_x = np.arange(num_epoch) * epoch_size
epoch_y = beta * np.power(scale, epoch_x)
epoch_y = np.maximum(epoch_y, beta_min)
# plot beta descent curve
plt.semilogy(x, y)
plt.semilogy(epoch_x, epoch_y, 'ro')
plt.title('beta descent')
plt.ylabel('beta')
plt.xlabel('epoch')
plt.show()
示例3: plot_error
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot_error(e, fname=None):
""" Plot the squared error versus time
Inputs:
e: vector of the error versus time
fname: what filename to export the figure to. If None, then doesn't
export
"""
plt.figure()
n = np.arange(len(e))
e2 = np.power(e, 2)
plt.plot(n, e2)
#plt.semilogy(n, e2)
plt.xlabel('Iteration')
plt.ylabel('Squared error')
if fname:
plt.savefig(fname)
plt.close()
示例4: plot_loss
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot_loss(loss_list, log_dir, iter_id):
def running_mean(x, N):
cumsum = np.cumsum(np.insert(x, 0, 0))
return (cumsum[N:] - cumsum[:-N]) / N
plt.figure()
plt.semilogy(loss_list, '.', alpha=0.2, label="Loss")
plt.semilogy(running_mean(loss_list,100), label="Average Loss")
plt.xlabel('Iterations')
plt.ylabel('Loss')
plt.legend()
plt.grid()
ax = plt.subplot(111)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.05),
ncol=3, fancybox=True, shadow=True)
plt.savefig(log_dir + "/fig_loss_iter_" + str(iter_id) + ".pdf")
print("figure plotted")
plt.close()
示例5: plot_loss_history
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot_loss_history(losshistory):
loss_train = np.sum(
np.array(losshistory.loss_train) * losshistory.loss_weights, axis=1
)
loss_test = np.sum(
np.array(losshistory.loss_test) * losshistory.loss_weights, axis=1
)
plt.figure()
plt.semilogy(losshistory.steps, loss_train, label="Train loss")
plt.semilogy(losshistory.steps, loss_test, label="Test loss")
for i in range(len(losshistory.metrics_test[0])):
plt.semilogy(
losshistory.steps,
np.array(losshistory.metrics_test)[:, i],
label="Test metric",
)
plt.xlabel("# Steps")
plt.legend()
示例6: semilogy
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def semilogy(x_vals, y_vals, x_label, y_label, x2_vals=None, y2_vals=None, legend=None):
plt.xlabel(x_label)
plt.ylabel(y_label)
plt.semilogy(x_vals, y_vals)
if x2_vals and y2_vals:
plt.semilogy(x2_vals, y2_vals, linestyle=':')
plt.legend(legend)
plt.show()
示例7: plot_error
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot_error(scales, relativ_error, scale0, title='', label=''):
plt.semilogy(scales, relativ_error, label=label)
plt.vlines(scale0, np.nanmin(relativ_error), 1)
plt.xlabel('scales')
plt.ylabel('Relative error')
plt.title(title)
plt.legend(frameon=False, framealpha=0.5)
plt.axis([min(scales), max(scales), np.nanmin(relativ_error), 1])
示例8: spectral_centroid
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def spectral_centroid(file):
y, sr = librosa.load(file)
cent = librosa.feature.spectral_centroid(y=y, sr=sr)
plt.figure()
plt.semilogy(cent.T, label='Spectral centroid')
plt.ylabel('Hz')
plt.xticks([])
plt.xlim([0, cent.shape[-1]])
plt.legend()
plt.title('log Power spectrogram')
plt.tight_layout()
示例9: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot(values, metric_name):
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import sys
plt.style.use('ggplot')
fig, ax = plt.subplots(1, 1, figsize=(25, 3))
ax.margins(0)
x = []
y = []
for index,v in enumerate( values ):
# if not index: continue
# plt.plot(x, new_recall, linewidth=2, label='Condensed Mem Network')
x.append(index)
y.append(v[1]['our']-v[1]['jpeg'])
# plt.plot(x,y, 'o')
# plt.semilogy(x,y)
y_neg = [max(0,i) for i in y]
y_pos = [min(0,i) for i in y]
plt.bar(x,y_neg)
plt.bar(x,y_pos, color='r')
plt.tick_params(axis='x', which='both', bottom='off', top='off', labelbottom='off')
plt.title(metric_name.upper(), x=0.5, y=0.8, fontsize=14)
plt.legend(loc='')
ax.get_xaxis().set_visible(False)
ax.xaxis.set_major_formatter(plt.NullFormatter())
fig.tight_layout()
# plt.savefig('plot_size_' + metric_name + '.png', bbox_inches='tight_layout', pad_inches=0)
plt.savefig('plot_kodak_' + metric_name + '.png')
示例10: test_log
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def test_log():
fig, axs = plt.subplots(2, 2, figsize=(10, 10))
for ax in axs[0]:
hep.histplot([1, 2, 3, 2], range(5), ax=ax)
plt.semilogy()
for ax in axs[1]:
hep.histplot([1, 2, 3, 2], range(5), ax=ax, edges=False)
plt.semilogy()
return fig
示例11: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot():
print(hyperparams.methodEvalString())
_, true_inl, _, R_errs, t_errs = cache.getOrEval()
assert R_errs[0] is not None
plt.semilogy(
true_inl, R_errs, 'o', label='R')
plt.semilogy(
true_inl, t_errs, 'v', label='t')
示例12: get_esd_plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def get_esd_plot(eigenvalues, weights):
density, grids = density_generate(eigenvalues, weights)
plt.semilogy(grids, density + 1.0e-7)
plt.ylabel('Density (Log Scale)', fontsize=14, labelpad=10)
plt.xlabel('Eigenvlaue', fontsize=14, labelpad=10)
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.axis([np.min(eigenvalues) - 1, np.max(eigenvalues) + 1, None, None])
plt.tight_layout()
plt.savefig('example.pdf')
示例13: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot(self):
from matplotlib import pyplot
pyplot.figure()
it_ls = [] #ls = lineseach
y_ls = []
it_ga = [] #gradient approximation
y_ga = []
gradApprox = False
for i in range(len(self.x)):
y = norm( self.f_x[i] ) + 10**-9
if i in self.notes:
if self.notes[i] == 'starting gradient approximation':
gradApprox = True
if self.notes[i] == 'finished gradient approximation':
gradApprox = False
if gradApprox:
it_ga.append( i )
y_ga.append( y )
else:
it_ls.append( i )
y_ls.append( y )
pyplot.semilogy( it_ls, y_ls, 'go')
pyplot.semilogy( it_ga, y_ga, 'bx')
pyplot.xlabel('function evaluation')
pyplot.ylabel('norm(f(x)) + 10**-9')
pyplot.legend(['line searches', 'gradient approx' ])
pyplot.show()
示例14: semilogy
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def semilogy(args, backend=None):
set_matplotlib_backend(backend=backend)
import matplotlib.pyplot as plt
plt.semilogy(*args)
plt.show()
示例15: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import semilogy [as 别名]
def plot(self, filedir=None, file_format='pdf'):
if filedir is None:
filedir = self.workdir
import matplotlib.pyplot as plt
plt.switch_backend('agg')
plt.figure(figsize=(8, 6))
plt.subplots_adjust(left=0.1, bottom=0.08, right=0.95, top=0.95, wspace=None, hspace=None)
forces = np.array(self.output['forces'])
maxforce = [np.max(np.apply_along_axis(np.linalg.norm, 1, x)) for x in forces]
avgforce = [np.mean(np.apply_along_axis(np.linalg.norm, 1, x)) for x in forces]
if np.max(maxforce) > 0.0 and np.max(avgforce) > 0.0:
plt.semilogy(maxforce, 'b.-', label='Max force')
plt.semilogy(avgforce, 'r.-', label='Mean force')
else:
plt.plot(maxforce, 'b.-', label='Max force')
plt.plot(avgforce, 'r.-', label='Mean force')
plt.xlabel('Ion movement iteration')
plt.ylabel('Max Force')
plt.savefig(filedir + os.sep + 'forces.' + file_format)
plt.clf()
plt.figure(figsize=(8, 6))
plt.subplots_adjust(left=0.1, bottom=0.08, right=0.95, top=0.95, wspace=None, hspace=None)
stress = np.array(self.output['stress'])
diag_stress = [np.trace(np.abs(x)) for x in stress]
offdiag_stress = [np.sum(np.abs(np.triu(x, 1).flatten())) for x in stress]
plt.semilogy(diag_stress, 'b.-', label='diagonal')
plt.semilogy(offdiag_stress, 'r.-', label='off-diagonal')
plt.legend()
plt.xlabel('Ion movement iteration')
plt.ylabel(r'$\sum |stress|$ (diag, off-diag)')
plt.savefig(filedir + os.sep + 'stress.' + file_format)