本文整理匯總了Python中seaborn.set_context方法的典型用法代碼示例。如果您正苦於以下問題:Python seaborn.set_context方法的具體用法?Python seaborn.set_context怎麽用?Python seaborn.set_context使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類seaborn
的用法示例。
在下文中一共展示了seaborn.set_context方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _plot_weights
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def _plot_weights(self, title, file, layer_index=0, vmin=-5, vmax=5):
import seaborn as sns
sns.set_context("paper")
layers = self.iwp.estimator.steps[-1][1].coefs_
layer = layers[layer_index]
f, ax = plt.subplots(figsize=(18, 12))
weights = pd.DataFrame(layer)
weights.index = self.iwp.inputs
sns.set(font_scale=1.1)
# Draw a heatmap with the numeric values in each cell
sns.heatmap(
weights, annot=True, fmt=".1f", linewidths=.5, ax=ax,
cmap="difference", center=0, vmin=vmin, vmax=vmax,
# annot_kws={"size":14},
)
ax.tick_params(labelsize=18)
f.tight_layout()
f.savefig(file)
示例2: plot_avg_return
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_avg_return(file_name, granularity):
plotting_data = torch.load(file_name + "_processed_data")
returns = plotting_data['returns']
unique_frames = plotting_data['unique_frames']
x_len = len(unique_frames)
x_index = [i for i in numpy.arange(0, x_len, granularity)]
x = unique_frames[::granularity]
y = numpy.transpose(numpy.array(returns)[x_index, :])
f, ax = plt.subplots(1, 1, figsize=[3, 2], dpi=300)
sns.set_style("ticks")
sns.set_context("paper")
# Find the order of magnitude of the last frame
order = int(math.log10(unique_frames[-1]))
range_frames = int(unique_frames[-1]/ (10**order))
sns.tsplot(data=y, time=numpy.array(x)/(10**order), color='b')
ax.set_xticks(numpy.arange(range_frames + 1))
plt.show()
f.savefig(file_name + "_avg_return.pdf", bbox_inches="tight")
plt.close(f)
示例3: plot_evaluation_episode_reward
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_evaluation_episode_reward():
pylab.clf()
sns.set_context("poster")
pylab.plot(0, 0)
episodes = [0]
average_scores = [0]
median_scores = [0]
for n in xrange(len(csv_evaluation)):
params = csv_evaluation[n]
episodes.append(params[0])
average_scores.append(params[1])
median_scores.append(params[2])
pylab.plot(episodes, average_scores, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("average score")
pylab.savefig("%s/evaluation_episode_average_reward.png" % args.plot_dir)
pylab.clf()
pylab.plot(0, 0)
pylab.plot(episodes, median_scores, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("median score")
pylab.savefig("%s/evaluation_episode_median_reward.png" % args.plot_dir)
示例4: plot_kim_curve
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_kim_curve(tmp):
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 5})
sns.set_style("darkgrid")
plt.figure(figsize=(20, 10))
plt.hold('on')
plt.plot(np.linspace(0, 0.3, 100), tmp['kc_avg'])
plt.ylim([0, 1])
# plt.figure(figsize=(10,5))
# plt.hold('on')
# legend = []
# for k,v in bench_res.iteritems():
# plt.plot(np.linspace(0, 0.3, 100), v['kc_avg'])
# legend.append(k)
# plt.ylim([0, 1])
# plt.legend(legend, loc='lower right')
示例5: learning_curve
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def learning_curve(self, idxs=[2,3,5,6]):
import seaborn as sns
import matplotlib.pyplot as plt
plt.switch_backend('agg')
# set style
sns.set_context("paper", font_scale=1.5,)
# sns.set_style("ticks", {
# "font.family": "Times New Roman",
# "font.serif": ["Times", "Palatino", "serif"]})
for idx in idxs:
plt.plot(self.logs[self.args.trigger],
self.logs[self.header[idx]], label=self.header[idx])
plt.ylabel(" {} / {} ".format(repr(self.criterion), repr(self.evaluator)))
if self.args.trigger == 'epoch':
plt.xlabel("Epochs")
else:
plt.xlabel("Iterations")
plt.suptitle("Training log of {}".format(self.method))
# remove top&left line
# sns.despine()
plt.legend(bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0.)
plt.savefig(os.path.join(Logs_DIR, 'curve', '{}.png'.format(self.repr)),
format='png', bbox_inches='tight', dpi=144)
示例6: __init__
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def __init__(self):
sns.set_style("ticks")
sns.set_context("paper", font_scale=1.5)
# color palette from colorbrewer (up to 4 colors, good for print and black&white printing)
# color_brewer_palette = ['#e66101', '#5e3c99', '#fdb863', '#b2abd2']
# most journals: 300dpi
plt.rcParams["savefig.dpi"] = 300
# most journals: 9 cm (or 3.5 inch) for single column width and 18.5 cm (or 7.3 inch) for double column width.
plt.rcParams["figure.autolayout"] = False
plt.rcParams["figure.figsize"] = 7.3, 4
plt.rcParams["axes.labelsize"] = 16
plt.rcParams["axes.titlesize"] = 16
plt.rcParams["xtick.labelsize"] = 16
plt.rcParams["ytick.labelsize"] = 16
plt.rcParams["font.size"] = 32
plt.rcParams["lines.linewidth"] = 2.0
plt.rcParams["lines.markersize"] = 8
plt.rcParams["legend.fontsize"] = 14
示例7: plotSleepValueHeatmap
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plotSleepValueHeatmap(intradayStats, sleepValue=1):
sns.set_context("poster")
sns.set_style("darkgrid")
xTicksDiv = 20
#stepSize = int(len(xticks)/xTicksDiv)
stepSize = 60
xticks = [x for x in intradayStats.columns.values]
keptticks = xticks[::stepSize]
xticks = ['' for _ in xticks]
xticks[::stepSize] = keptticks
plt.figure(figsize=(16, 4.2))
g = sns.heatmap(intradayStats.loc[sleepValue].reshape(1,-1))
g.set_xticklabels(xticks, rotation=45)
g.set_yticklabels([])
g.set_ylabel(sleepStats.SLEEP_VALUES[sleepValue])
plt.tight_layout()
sns.plt.show()
示例8: configure_plt
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def configure_plt():
rc('font', **{'family': 'sans-serif',
'sans-serif': ['Computer Modern Roman']})
params = {'axes.labelsize': 12,
'font.size': 12,
'legend.fontsize': 12,
'xtick.labelsize': 10,
'ytick.labelsize': 10,
'text.usetex': True,
'figure.figsize': (8, 6)}
plt.rcParams.update(params)
sns.set_palette('colorblind')
sns.set_context("poster")
sns.set_style("ticks")
示例9: make_slashdot_figures
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def make_slashdot_figures(output_path_prefix, method_name_list, slashdot_mse, slashdot_jaccard, slashdot_k_list):
sns.set_style("darkgrid")
sns.set_context("paper")
translator = get_method_name_to_legend_name_dict()
slashdot_k_list = list(slashdot_k_list)
fig, axes = plt.subplots(1, 2, sharex=True)
axes[0].set_title("SlashDot Comments")
axes[1].set_title("SlashDot Users")
plt.locator_params(nbins=8)
# Comments
for m, method in enumerate(method_name_list):
axes[0].set_ylabel("MSE")
axes[0].set_xlabel("Lifetime (sec)")
axes[0].plot(slashdot_k_list[1:],
handle_nan(slashdot_mse[method]["comments"].mean(axis=1))[1:],
label=translator[method])
# Users
for m, method in enumerate(method_name_list):
# axes[1].set_ylabel("MSE")
axes[1].set_xlabel("Lifetime (sec)")
axes[1].plot(slashdot_k_list[1:],
handle_nan(slashdot_mse[method]["users"].mean(axis=1))[1:],
label=translator[method])
axes[1].legend(loc="upper right")
# plt.show()
plt.savefig(output_path_prefix + "_mse_slashdot_SNOW" + ".png", format="png")
plt.savefig(output_path_prefix + "_mse_slashdot_SNOW" + ".eps", format="eps")
示例10: make_barrapunto_figures
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def make_barrapunto_figures(output_path_prefix, method_name_list, barrapunto_mse, barrapunto_jaccard, barrapunto_k_list):
sns.set_style("darkgrid")
sns.set_context("paper")
translator = get_method_name_to_legend_name_dict()
barrapunto_k_list = list(barrapunto_k_list)
fig, axes = plt.subplots(1, 2, sharex=True)
axes[0].set_title("BarraPunto Comments")
axes[1].set_title("BarraPunto Users")
plt.locator_params(nbins=8)
# Comments
for m, method in enumerate(method_name_list):
axes[0].set_ylabel("MSE")
axes[0].set_xlabel("Lifetime (sec)")
axes[0].plot(barrapunto_k_list[1:],
handle_nan(barrapunto_mse[method]["comments"].mean(axis=1))[1:],
label=translator[method])
# Users
for m, method in enumerate(method_name_list):
# axes[1].set_ylabel("MSE")
axes[1].set_xlabel("Lifetime (sec)")
axes[1].plot(barrapunto_k_list[1:],
handle_nan(barrapunto_mse[method]["users"].mean(axis=1))[1:],
label=translator[method])
axes[1].legend(loc="upper right")
# plt.show()
plt.savefig(output_path_prefix + "_mse_barrapunto_SNOW" + ".png", format="png")
plt.savefig(output_path_prefix + "_mse_barrapunto_SNOW" + ".eps", format="eps")
示例11: set_context
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def set_context(context="talk"):
sns.set_context(context)
示例12: plot_gp
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_gp():
np.random.seed(12345)
sns.set_context("paper", font_scale=0.65)
X_test = np.linspace(-10, 10, 100)
X_train = np.array([-3, 0, 7, 1, -9])
y_train = np.sin(X_train)
fig, axes = plt.subplots(2, 2)
alphas = [0, 1e-10, 1e-5, 1]
for ix, (ax, alpha) in enumerate(zip(axes.flatten(), alphas)):
G = GPRegression(kernel="RBFKernel", alpha=alpha)
G.fit(X_train, y_train)
y_pred, conf = G.predict(X_test)
ax.plot(X_train, y_train, "rx", label="observed")
ax.plot(X_test, np.sin(X_test), label="true fn")
ax.plot(X_test, y_pred, "--", label="MAP (alpha={})".format(alpha))
ax.fill_between(X_test, y_pred + conf, y_pred - conf, alpha=0.1)
ax.set_xticks([])
ax.set_yticks([])
sns.despine()
ax.legend()
plt.tight_layout()
plt.savefig("img/gp_alpha.png", dpi=300)
plt.close("all")
示例13: plot_results
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_results(res, path):
"""Some results plots"""
if res is None or len(res) == 0:
return
counts = base.pivot_count_data(res, idxcols=['name','ref'])
x = base.get_fractions_mapped(res)
print (x)
import seaborn as sns
sns.set_style('white')
sns.set_context("paper",font_scale=1.2)
fig = plotting.plot_fractions(x)
fig.savefig(os.path.join(path,'libraries_mapped.png'))
fig = plotting.plot_sample_counts(counts)
fig.savefig(os.path.join(path,'total_per_sample.png'))
fig = plotting.plot_read_count_dists(counts)
fig.savefig(os.path.join(path,'top_mapped.png'))
scols,ncols = base.get_column_names(counts)
for l,df in counts.groupby('ref'):
if 'mirbase' in l:
fig = plotting.plot_read_count_dists(df)
fig.savefig(os.path.join(path,'top_%s.png' %l))
#if len(scols)>1:
# fig = plotting.expression_clustermap(counts)
# fig.savefig(os.path.join(path,'expr_map.png'))
return
示例14: plot_episode_reward
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_episode_reward():
pylab.clf()
sns.set_context("poster")
pylab.plot(0, 0)
episodes = [0]
scores = [0]
for n in xrange(len(csv_episode)):
params = csv_episode[n]
episodes.append(params[0])
scores.append(params[1])
pylab.plot(episodes, scores, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("score")
pylab.savefig("%s/episode_reward.png" % args.plot_dir)
示例15: plot_training_episode_highscore
# 需要導入模塊: import seaborn [as 別名]
# 或者: from seaborn import set_context [as 別名]
def plot_training_episode_highscore():
pylab.clf()
sns.set_context("poster")
pylab.plot(0, 0)
episodes = [0]
highscore = [0]
for n in xrange(len(csv_training_highscore)):
params = csv_training_highscore[n]
episodes.append(params[0])
highscore.append(params[1])
pylab.plot(episodes, highscore, sns.xkcd_rgb["windows blue"], lw=2)
pylab.xlabel("episodes")
pylab.ylabel("highscore")
pylab.savefig("%s/training_episode_highscore.png" % args.plot_dir)