本文整理汇总了Python中seaborn.regplot方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.regplot方法的具体用法?Python seaborn.regplot怎么用?Python seaborn.regplot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类seaborn
的用法示例。
在下文中一共展示了seaborn.regplot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: yield_by_minimal_length_plot
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def yield_by_minimal_length_plot(array, name, path,
title=None, color="#4CB391", figformat="png"):
df = pd.DataFrame(data={"lengths": np.sort(array)[::-1]})
df["cumyield_gb"] = df["lengths"].cumsum() / 10**9
yield_by_length = Plot(
path=path + "Yield_By_Length." + figformat,
title="Yield by length")
ax = sns.regplot(
x='lengths',
y="cumyield_gb",
data=df,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(
xlabel='Read length',
ylabel='Cumulative yield for minimal length',
title=title or yield_by_length.title)
yield_by_length.fig = ax.get_figure()
yield_by_length.save(format=figformat)
plt.close("all")
return yield_by_length
示例2: RelativeDegradation
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def RelativeDegradation(combined_stat_df):
"""
This function analyzes the relative degradation of one or more functions.
"""
# print(combined_stat_df)
fig, axs = plt.subplots(ncols=1, sharex=True)
# combined_stat_df.plot(kind='scatter', x='rate', y='rel_stress',
# alpha=0.5, marker='o', ax=axs[0])
# combined_stat_df.plot(kind='line', x='rate', y='throughput',
# alpha=0.5, marker='o', ax=axs[1])
# sns.relplot(data=combined_stat_df, x='rate', y='throughput', ax=axs[1], kind='line')
function_of_interest = 'rand_vector_loop_d'
test_cats = set(combined_stat_df['Test Category'])
for test_cat in test_cats:
df = combined_stat_df[combined_stat_df['Test Category'] == test_cat]
df = df[df['func_name'] == function_of_interest]
sns.regplot(data=df, x='rate', y='throughput',
ax=axs, order=2, truncate=True)
plt.xlabel('test')
plt.ylabel('Function Throughput')
plt.show()
plt.close()
示例3: plot_eval
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_eval(self, eval_dict, labels, path_extension=""):
"""
Plot the loss function in a overall plot and a zoomed plot.
:param path_extension: If the plot should be saved in an incremental way.
"""
def plot(x, y, fit, label):
sns.regplot(np.array(x), np.array(y), fit_reg=fit, label=label, scatter_kws={"s": 5})
plt.clf()
plt.subplot(211)
idx = np.array(eval_dict.values()[0]).shape[0]
x = np.array(eval_dict.values())
for i in range(idx):
plot(eval_dict.keys(), x[:, i], False, labels[i])
plt.legend()
plt.subplot(212)
for i in range(idx):
plot(eval_dict.keys()[-int(len(x) * 0.25):], x[-int(len(x) * 0.25):][:, i], True, labels[i])
plt.xlabel('Epochs')
plt.savefig(paths.get_plot_evaluation_path_for_model(self.model.get_root_path(), path_extension+".png"))
示例4: visualize_results
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def visualize_results(df):
# Visualize logistic curve using seaborn
sns.set(style="darkgrid")
sns.regplot(x="pageviews_cumsum",
y="is_conversion",
data=df,
logistic=True,
n_boot=500,
y_jitter=.01,
scatter_kws={"s": 60})
sns.set(font_scale=1.3)
sns.plt.title('Logistic Regression Curve')
sns.plt.ylabel('Conversion probability')
sns.plt.xlabel('Cumulative sum of pageviews')
sns.plt.subplots_adjust(right=0.93, top=0.90, left=0.10, bottom=0.10)
sns.plt.show()
# Run the final program
开发者ID:thomhopmans,项目名称:themarketingtechnologist,代码行数:21,代码来源:business_case_solver_without_classes.py
示例5: visualize_results
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def visualize_results(self):
# Visualize logistic curve using seaborn
sns.set(style="darkgrid")
sns.regplot(x="pageviews_cumsum",
y="is_conversion",
data=self.df,
logistic=True,
n_boot=500,
y_jitter=.01,
scatter_kws={"s": 60})
sns.set(font_scale=1.3)
sns.plt.title('Logistic Regression Curve')
sns.plt.ylabel('Conversion probability')
sns.plt.xlabel('Cumulative sum of pageviews')
sns.plt.subplots_adjust(right=0.93, top=0.90, left=0.10, bottom=0.10)
sns.plt.show()
示例6: plot_over_time
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_over_time(dfs, path, figformat, title, color):
num_reads = Plot(path=path + "NumberOfReads_Over_Time." + figformat,
title="Number of reads over time")
s = dfs.loc[:, "lengths"].resample('10T').count()
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y=s,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(xlabel='Run time (hours)',
ylabel='Number of reads per 10 minutes',
title=title or num_reads.title)
num_reads.fig = ax.get_figure()
num_reads.save(format=figformat)
plt.close("all")
plots = [num_reads]
if "channelIDs" in dfs:
pores_over_time = Plot(path=path + "ActivePores_Over_Time." + figformat,
title="Number of active pores over time")
s = dfs.loc[:, "channelIDs"].resample('10T').nunique()
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y=s,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(xlabel='Run time (hours)',
ylabel='Active pores per 10 minutes',
title=title or pores_over_time.title)
pores_over_time.fig = ax.get_figure()
pores_over_time.save(format=figformat)
plt.close("all")
plots.append(pores_over_time)
return plots
示例7: cumulative_yield
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def cumulative_yield(dfs, path, figformat, title, color):
cum_yield_gb = Plot(path=path + "CumulativeYieldPlot_Gigabases." + figformat,
title="Cumulative yield")
s = dfs.loc[:, "lengths"].cumsum().resample('1T').max() / 1e9
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y=s,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(xlabel='Run time (hours)',
ylabel='Cumulative yield in gigabase',
title=title or cum_yield_gb.title)
cum_yield_gb.fig = ax.get_figure()
cum_yield_gb.save(format=figformat)
plt.close("all")
cum_yield_reads = Plot(path=path + "CumulativeYieldPlot_NumberOfReads." + figformat,
title="Cumulative yield")
s = dfs.loc[:, "lengths"].resample('10T').count().cumsum()
ax = sns.regplot(x=s.index.total_seconds() / 3600,
y=s,
x_ci=None,
fit_reg=False,
color=color,
scatter_kws={"s": 3})
ax.set(xlabel='Run time (hours)',
ylabel='Cumulative yield in number of reads',
title=title or cum_yield_reads.title)
cum_yield_reads.fig = ax.get_figure()
cum_yield_reads.save(format=figformat)
plt.close("all")
return [cum_yield_gb, cum_yield_reads]
示例8: regplot
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def regplot(vals1, vals2, out_pdf, alpha=0.5, x_label=None, y_label=None):
plt.figure()
gold = sns.color_palette('husl', 8)[1]
ax = sns.regplot(
vals1,
vals2,
color='black',
lowess=True,
scatter_kws={'color': 'black',
's': 4,
'alpha': alpha},
line_kws={'color': gold})
xmin, xmax = plots.scatter_lims(vals1)
ymin, ymax = plots.scatter_lims(vals2)
ax.set_xlim(xmin, xmax)
if x_label is not None:
ax.set_xlabel(x_label)
ax.set_ylim(ymin, ymax)
if y_label is not None:
ax.set_ylabel(y_label)
ax.grid(True, linestyle=':')
plt.savefig(out_pdf)
plt.close()
################################################################################
# __main__
################################################################################
示例9: regplot_gc
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def regplot_gc(vals1, vals2, model, out_pdf):
gold = sns.color_palette('husl', 8)[1]
plt.figure(figsize=(6, 6))
# plot data and seaborn model
ax = sns.regplot(
vals1,
vals2,
color='black',
order=3,
scatter_kws={'color': 'black',
's': 4,
'alpha': 0.5},
line_kws={'color': gold})
# plot my model predictions
svals1 = np.sort(vals1)
preds2 = model.predict(svals1[:, np.newaxis])
ax.plot(svals1, preds2)
# adjust axis
ymin, ymax = scatter_lims(vals2)
ax.set_xlim(0.2, 0.8)
ax.set_xlabel('GC%')
ax.set_ylim(ymin, ymax)
ax.set_ylabel('Coverage')
ax.grid(True, linestyle=':')
plt.savefig(out_pdf)
plt.close()
示例10: regplot_shift
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def regplot_shift(vals1, vals2, preds2, out_pdf):
gold = sns.color_palette('husl', 8)[1]
plt.figure(figsize=(6, 6))
# plot data and seaborn model
ax = sns.regplot(
vals1,
vals2,
color='black',
order=3,
scatter_kws={'color': 'black',
's': 4,
'alpha': 0.5},
line_kws={'color': gold})
# plot my model predictions
ax.plot(vals1, preds2)
# adjust axis
ymin, ymax = scatter_lims(vals2)
ax.set_xlabel('Shift')
ax.set_ylim(ymin, ymax)
ax.set_ylabel('Covariance')
ax.grid(True, linestyle=':')
plt.savefig(out_pdf)
plt.close()
示例11: run_spearmanr
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def run_spearmanr(df, condition_col, value_col='acc_diff', log=False,
plot=False):
"""Run Spearman's rank correlation analysis.
Args:
df (pd.DataFrame): dataframe where each row is a paper.
condition_col (str): name of column to use as condition.
Keyword Args:
value_col (str): name of column to use as the numerical value to run the
test on.
log (bool): if True, use log of `condition_col` before computing the
correlation.
Returns:
(float): U statistic
(float): p-value
"""
data1 = np.log10(df[condition_col]) if log else df[condition_col]
data2 = df[value_col]
corr, p = spearmanr(data1, data2)
if plot:
log_condition_col = 'log_' + condition_col
df[log_condition_col] = np.log10(df[condition_col])
fig, ax = plt.subplots()
sns.regplot(data=df, x=log_condition_col, y=value_col, robust=True, ax=ax)
ax.set_title('Spearman Rho for {} vs. {}\n(pvalue={:0.4f}, ρ={:0.4f})'.format(
log_condition_col, value_col, p, corr))
else:
fig = None
return {'test': 'spearmanr', 'pvalue': p, 'stat': corr, 'fig': fig}
示例12: plot_correlation
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_correlation(x, y, data, title=None, color=None, kind='joint', ax=None):
# Extract only logP values.
data = data[[x, y]]
# Find extreme values to make axes equal.
min_limit = np.ceil(min(data.min()) - 1)
max_limit = np.floor(max(data.max()) + 1)
axes_limits = np.array([min_limit, max_limit])
if kind == 'joint':
grid = sns.jointplot(x=x, y=y, data=data,
kind='reg', joint_kws={'ci': None}, stat_func=None,
xlim=axes_limits, ylim=axes_limits, color=color)
ax = grid.ax_joint
grid.fig.subplots_adjust(top=0.95)
grid.fig.suptitle(title)
elif kind == 'reg':
ax = sns.regplot(x=x, y=y, data=data, color=color, ax=ax)
ax.set_title(title)
# Add diagonal line.
ax.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7)
# Add shaded area for 0.5-1 logP error.
palette = sns.color_palette('BuGn_r')
ax.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2])
ax.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3])
示例13: plot_correlation_with_SEM
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_correlation_with_SEM(x_lab, y_lab, x_err_lab, y_err_lab, data, title=None, color=None, ax=None):
# Extract only logP values.
x_error = data.loc[:, x_err_lab]
y_error = data.loc[:, y_err_lab]
x_values = data.loc[:, x_lab]
y_values = data.loc[:, y_lab]
data = data[[x_lab, y_lab]]
# Find extreme values to make axes equal.
min_limit = np.ceil(min(data.min()) - 1)
max_limit = np.floor(max(data.max()) + 1)
axes_limits = np.array([min_limit, max_limit])
# Color
current_palette = sns.color_palette()
sns_blue = current_palette[0]
# Plot
plt.figure(figsize=(6, 6))
grid = sns.regplot(x=x_values, y=y_values, data=data, color=color, ci=None)
plt.errorbar(x=x_values, y=y_values, xerr=x_error, yerr=y_error, fmt="o", ecolor=sns_blue, capthick='2',
label='SEM', alpha=0.75)
plt.axis("equal")
if len(title) > 70:
plt.title(title[:70]+"...")
else:
plt.title(title)
# Add diagonal line.
grid.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7)
# Add shaded area for 0.5-1 logP error.
palette = sns.color_palette('BuGn_r')
grid.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2])
grid.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3])
plt.xlim(axes_limits)
plt.ylim(axes_limits)
示例14: plot_correlation
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_correlation(x, y, data, title=None, color=None, kind='joint', ax=None):
# Extract only pKa values.
data = data[[x, y]]
# Find extreme values to make axes equal.
min_limit = np.ceil(min(data.min()) - 2)
max_limit = np.floor(max(data.max()) + 2)
axes_limits = np.array([min_limit, max_limit])
if kind == 'joint':
grid = sns.jointplot(x=x, y=y, data=data,
kind='reg', joint_kws={'ci': None}, stat_func=None,
xlim=axes_limits, ylim=axes_limits, color=color)
ax = grid.ax_joint
grid.fig.subplots_adjust(top=0.95)
grid.fig.suptitle(title)
elif kind == 'reg':
ax = sns.regplot(x=x, y=y, data=data, color=color, ax=ax)
ax.set_title(title)
# Add diagonal line.
ax.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7)
# Add shaded area for 0.5-1 pKa error.
palette = sns.color_palette('BuGn_r')
ax.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2])
ax.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3])
示例15: plot_correlation_with_SEM
# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import regplot [as 别名]
def plot_correlation_with_SEM(x_lab, y_lab, x_err_lab, y_err_lab, data, title=None, color=None, ax=None):
# Extract only pKa values.
x_error = data.loc[:, x_err_lab]
y_error = data.loc[:, y_err_lab]
x_values = data.loc[:, x_lab]
y_values = data.loc[:, y_lab]
data = data[[x_lab, y_lab]]
# Find extreme values to make axes equal.
min_limit = np.ceil(min(data.min()) - 2)
max_limit = np.floor(max(data.max()) + 2)
axes_limits = np.array([min_limit, max_limit])
# Color
current_palette = sns.color_palette()
sns_blue = current_palette[0]
# Plot
plt.figure(figsize=(6, 6))
grid = sns.regplot(x=x_values, y=y_values, data=data, color=color, ci=None)
plt.errorbar(x=x_values, y=y_values, xerr=x_error, yerr=y_error, fmt="o", ecolor=sns_blue, capthick='2',
label='SEM', alpha=0.75)
plt.axis("equal")
if len(title) > 70:
plt.title(title[:70]+"...")
else:
plt.title(title)
# Add diagonal line.
grid.plot(axes_limits, axes_limits, ls='--', c='black', alpha=0.8, lw=0.7)
# Add shaded area for 0.5-1 pKa error.
palette = sns.color_palette('BuGn_r')
grid.fill_between(axes_limits, axes_limits - 0.5, axes_limits + 0.5, alpha=0.2, color=palette[2])
grid.fill_between(axes_limits, axes_limits - 1, axes_limits + 1, alpha=0.2, color=palette[3])
plt.xlim(axes_limits)
plt.ylim(axes_limits)