本文整理汇总了Python中matplotlib.pyplot.xscale方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.xscale方法的具体用法?Python pyplot.xscale怎么用?Python pyplot.xscale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.xscale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _plot_matplotlib
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def _plot_matplotlib(subset_sizes, data_list, mmr):
""" Plots learning curve using matplotlib backend.
Args:
subset_sizes: list of dataset sizes on which the evaluation was done
data_list: list of ROC AUC scores corresponding to subset_sizes
mmr: what MMR the data is taken from
"""
plt.plot(subset_sizes, data_list[0], lw=2)
plt.plot(subset_sizes, data_list[1], lw=2)
plt.legend(['Cross validation error', 'Test error'])
plt.xscale('log')
plt.xlabel('Dataset size')
plt.ylabel('Error')
if mmr:
plt.title('Learning curve plot for %d MMR' % mmr)
else:
plt.title('Learning curve plot')
plt.show()
示例2: plot_cumulative_recall_differences
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot_cumulative_recall_differences(cumulative_recalls, path):
"""Plot differences in cumulative recall between groups up to time T."""
plt.figure(figsize=(8, 3))
style = {'dynamic': '-', 'static': '--'}
for setting, recalls in cumulative_recalls.items():
abs_array = np.mean(np.abs(recalls[0::2, :] - recalls[1::2, :]), axis=0)
plt.plot(abs_array, style[setting], label=setting)
plt.title(
'Recall gap for EO agent in dynamic vs static environments', fontsize=16)
plt.yscale('log')
plt.xscale('log')
plt.ylabel('TPR gap', fontsize=16)
plt.xlabel('# steps', fontsize=16)
plt.grid(True)
plt.legend()
plt.tight_layout()
_write(path)
示例3: plot_loss_change
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot_loss_change(self, sma=1, n_skip_beginning=10, n_skip_end=5, y_lim=(-0.01, 0.01)):
"""
Plots rate of change of the loss function.
Parameters:
sma - number of batches for simple moving average to smooth out the curve.
n_skip_beginning - number of batches to skip on the left.
n_skip_end - number of batches to skip on the right.
y_lim - limits for the y axis.
"""
derivatives = self.get_derivatives(sma)[n_skip_beginning:-n_skip_end]
lrs = self.lrs[n_skip_beginning:-n_skip_end]
plt.ylabel("rate of loss change")
plt.xlabel("learning rate (log scale)")
plt.plot(lrs, derivatives)
plt.xscale('log')
plt.ylim(y_lim)
plt.show()
示例4: plot_alt_temp_mole
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot_alt_temp_mole(atmosphere=None, temp=None, alt_ref=None, mole=None):
"""Plot-helping function
"""
if atmosphere is True:
alt, pre, temp, mole, alt_ref = swifile(atmosphere)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(mole*1.e-6,alt_ref,'b-') # ,label='Number density(SSL=60)')
plt.xlabel('Number density [cm$^{-3}$]',fontsize=18,weight='bold')
plt.xscale('log')
plt.ylabel('Altitude [km]',fontsize=18,weight='bold')
ax2=ax.twiny()
ax2.plot(temp,alt_ref,'k-', label='Temperature')
ax2.set_xlabel("Temperature [K]",fontsize=18,weight='bold')
ax2.plot([],[],'b-', label='H$_{2}$O Number density')
plt.legend()
fig.tight_layout(pad=0.4)
return fig
示例5: figure_5_4
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def figure_5_4():
runs = 10
episodes = 100000
for run in range(runs):
rewards = []
for episode in range(0, episodes):
reward, trajectory = play()
if trajectory[-1] == ACTION_END:
rho = 0
else:
rho = 1.0 / pow(0.5, len(trajectory))
rewards.append(rho * reward)
rewards = np.add.accumulate(rewards)
estimations = np.asarray(rewards) / np.arange(1, episodes + 1)
plt.plot(estimations)
plt.xlabel('Episodes (log scale)')
plt.ylabel('Ordinary Importance Sampling')
plt.xscale('log')
plt.savefig('../images/figure_5_4.png')
plt.close()
示例6: figure_5_3
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def figure_5_3():
true_value = -0.27726
episodes = 10000
runs = 100
error_ordinary = np.zeros(episodes)
error_weighted = np.zeros(episodes)
for i in tqdm(range(0, runs)):
ordinary_sampling_, weighted_sampling_ = monte_carlo_off_policy(episodes)
# get the squared error
error_ordinary += np.power(ordinary_sampling_ - true_value, 2)
error_weighted += np.power(weighted_sampling_ - true_value, 2)
error_ordinary /= runs
error_weighted /= runs
plt.plot(error_ordinary, label='Ordinary Importance Sampling')
plt.plot(error_weighted, label='Weighted Importance Sampling')
plt.xlabel('Episodes (log scale)')
plt.ylabel('Mean square error')
plt.xscale('log')
plt.legend()
plt.savefig('../images/figure_5_3.png')
plt.close()
示例7: diagnostics_SNR
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def diagnostics_SNR(self):
""" Plots SNR distributions of ref and test object spectra """
print("Diagnostic for SNRs of reference and survey objects")
fig = plt.figure()
data = self.test_SNR
plt.hist(data, bins=int(np.sqrt(len(data))), alpha=0.5, facecolor='r',
label="Survey Objects")
data = self.tr_SNR
plt.hist(data, bins=int(np.sqrt(len(data))), alpha=0.5, color='b',
label="Ref Objects")
plt.legend(loc='upper right')
#plt.xscale('log')
plt.title("SNR Comparison Between Reference and Survey Objects")
#plt.xlabel("log(Formal SNR)")
plt.xlabel("Formal SNR")
plt.ylabel("Number of Objects")
return fig
示例8: example1
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def example1():
"""
Compute the GRADEV of a white phase noise. Compares two different
scenarios. 1) The original data and 2) ADEV estimate with gap robust ADEV.
"""
N = 1000
f = 1
y = np.random.randn(1,N)[0,:]
x = [xx for xx in np.linspace(1,len(y),len(y))]
x_ax, y_ax, (err_l, err_h), ns = allan.gradev(y,data_type='phase',rate=f,taus=x)
plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h],label='GRADEV, no gaps')
y[int(np.floor(0.4*N)):int(np.floor(0.6*N))] = np.NaN # Simulate missing data
x_ax, y_ax, (err_l, err_h) , ns = allan.gradev(y,data_type='phase',rate=f,taus=x)
plt.errorbar(x_ax, y_ax,yerr=[err_l,err_h], label='GRADEV, with gaps')
plt.xscale('log')
plt.yscale('log')
plt.grid()
plt.legend()
plt.xlabel('Tau / s')
plt.ylabel('Overlapping Allan deviation')
plt.show()
示例9: test_markevery_log_scales
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def test_markevery_log_scales():
cases = [None,
8,
(30, 8),
[16, 24, 30], [0,-1],
slice(100, 200, 3),
0.1, 0.3, 1.5,
(0.0, 0.1), (0.45, 0.1)]
cols = 3
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
delta = 0.11
x = np.linspace(0, 10 - 2 * delta, 200) + delta
y = np.sin(x) + 1.0 + delta
for i, case in enumerate(cases):
row = (i // cols)
col = i % cols
plt.subplot(gs[row, col])
plt.title('markevery=%s' % str(case))
plt.xscale('log')
plt.yscale('log')
plt.plot(x, y, 'o', ls='-', ms=4, markevery=case)
示例10: _save_plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def _save_plot(learning_rates: List[float], losses: List[float], save_path: str):
try:
import matplotlib
matplotlib.use("Agg") # noqa
import matplotlib.pyplot as plt
except ModuleNotFoundError as error:
logger.warn(
"To use allennlp find-learning-rate, please install matplotlib: pip install matplotlib>=2.2.3 ."
)
raise error
plt.ylabel("loss")
plt.xlabel("learning rate (log10 scale)")
plt.xscale("log")
plt.plot(learning_rates, losses)
logger.info(f"Saving learning_rate vs loss plot to {save_path}.")
plt.savefig(save_path)
示例11: test_markevery_log_scales
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def test_markevery_log_scales():
cases = [None,
8,
(30, 8),
[16, 24, 30], [0, -1],
slice(100, 200, 3),
0.1, 0.3, 1.5,
(0.0, 0.1), (0.45, 0.1)]
cols = 3
gs = matplotlib.gridspec.GridSpec(len(cases) // cols + 1, cols)
delta = 0.11
x = np.linspace(0, 10 - 2 * delta, 200) + delta
y = np.sin(x) + 1.0 + delta
for i, case in enumerate(cases):
row = (i // cols)
col = i % cols
plt.subplot(gs[row, col])
plt.title('markevery=%s' % str(case))
plt.xscale('log')
plt.yscale('log')
plt.plot(x, y, 'o', ls='-', ms=4, markevery=case)
示例12: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot(self, n_skip:int=0, n_max:Optional[int]=None, lim_y:Optional[Tuple[float,float]]=None) -> None:
r'''
Plot the loss as a function of the LR.
Arguments:
n_skip: Number of initial iterations to skip in plotting
n_max: Maximum iteration number to plot
lim_y: y-range for plotting
'''
# TODO: Decide on whether to keep this; could just pass to plot_lr_finders
with sns.axes_style(self.plot_settings.style), sns.color_palette(self.plot_settings.cat_palette):
plt.figure(figsize=(self.plot_settings.w_mid, self.plot_settings.h_mid))
plt.plot(self.history['lr'][n_skip:n_max], self.history['loss'][n_skip:n_max], label='Training loss', color='g')
if np.log10(self.lr_bounds[1])-np.log10(self.lr_bounds[0]) >= 3: plt.xscale('log')
plt.ylim(lim_y)
plt.grid(True, which="both")
plt.legend(loc=self.plot_settings.leg_loc, fontsize=self.plot_settings.leg_sz)
plt.xticks(fontsize=self.plot_settings.tk_sz, color=self.plot_settings.tk_col)
plt.yticks(fontsize=self.plot_settings.tk_sz, color=self.plot_settings.tk_col)
plt.ylabel("Loss", fontsize=self.plot_settings.lbl_sz, color=self.plot_settings.lbl_col)
plt.xlabel("Learning rate", fontsize=self.plot_settings.lbl_sz, color=self.plot_settings.lbl_col)
plt.show()
示例13: plot_classif_perf
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot_classif_perf(list_overall_best_score_classif, list_overall_best_score_classes_classif, list_num_samples,
Dataset):
for iter, [scores_classif, dataset, method, num_task] in enumerate(list_overall_best_score_classif):
if dataset == Dataset and num_task == 1 and method == "Baseline":
scores_mean = scores_classif.mean(0)
scores_std = scores_classif.std(0)
# there should be only one curve by dataset
plt.plot(list_num_samples, scores_mean)
plt.fill_between(list_num_samples, scores_mean - scores_std, scores_mean + scores_std, alpha=0.4)
plt.xscale('log')
plt.xlabel("Number of Samples")
plt.ylabel("Accuracy")
plt.ylim([0, 100])
plt.title('Accuracy in fonction number of samples used')
plt.savefig(os.path.join(save_dir, Dataset + "_Accuracy_NbSamples.png"))
plt.clf()
示例14: plot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def plot(self, min_val=-10, max_val=10, step_size=0.1, figsize=(10, 5), xlabel=None, ylabel='Probability', xticks=None, yticks=None, log_xscale=False, log_yscale=False, file_name=None, show=True, fig=None, *args, **kwargs):
if fig is None:
if not show:
mpl.rcParams['axes.unicode_minus'] = False
plt.switch_backend('agg')
fig = plt.figure(figsize=figsize)
fig.tight_layout()
xvals = np.arange(min_val, max_val, step_size)
plt.plot(xvals, [torch.exp(self.log_prob(x)) for x in xvals], *args, **kwargs)
if log_xscale:
plt.xscale('log')
if log_yscale:
plt.yscale('log', nonposy='clip')
if xticks is not None:
plt.xticks(xticks)
if yticks is not None:
plt.xticks(yticks)
# if xlabel is None:
# xlabel = self.name
plt.xlabel(xlabel)
plt.ylabel(ylabel)
if file_name is not None:
plt.savefig(file_name)
if show:
plt.show()
示例15: test_ioworker_performance
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import xscale [as 别名]
def test_ioworker_performance(nvme0n1):
import matplotlib.pyplot as plt
output_io_per_second = []
percentile_latency = dict.fromkeys([90, 99, 99.9, 99.99, 99.999])
nvme0n1.ioworker(io_size=8,
lba_random=True,
read_percentage=100,
output_io_per_second=output_io_per_second,
output_percentile_latency=percentile_latency,
time=10).start().close()
logging.info(output_io_per_second)
logging.info(percentile_latency)
X = []
Y = []
for _, k in enumerate(percentile_latency):
X.append(k)
Y.append(percentile_latency[k])
plt.plot(X, Y)
plt.xscale('log')
plt.yscale('log')
#plt.show()