Python seaborn.plotting_context() Examples
The following are 6
code examples of seaborn.plotting_context().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
seaborn
, or try the search function
.
Example #1
Source File: plotting_utils.py From QUANTAXIS with MIT License | 6 votes |
def customize(func): """ 修饰器,设置输出图像内容与风格 """ @wraps(func) def call_w_context(*args, **kwargs): set_context = kwargs.pop("set_context", True) if set_context: color_palette = sns.color_palette("colorblind") with plotting_context(), axes_style(), color_palette: sns.despine(left=True) return func(*args, **kwargs) else: return func(*args, **kwargs) return call_w_context
Example #2
Source File: plotting_utils.py From QUANTAXIS with MIT License | 6 votes |
def plotting_context( context: str = "notebook", font_scale: float = 1.5, rc: dict = None ): """ 创建默认画图板样式 参数 --- :param context: seaborn 样式 :param font_scale: 设置字体大小 :param rc: 配置标签 """ if rc is None: rc = {} rc_default = {"lines.linewidth": 1.5} # 如果没有默认设置,增加默认设置 for name, val in rc_default.items(): rc.setdefault(name, val) return sns.plotting_context(context=context, font_scale=font_scale, rc=rc)
Example #3
Source File: plot_utils.py From jqfactor_analyzer with MIT License | 6 votes |
def customize(func): @wraps(func) def call_w_context(*args, **kwargs): if not PlotConfig.FONT_SETTED: _use_chinese(True) set_context = kwargs.pop('set_context', True) if set_context: with plotting_context(), axes_style(): sns.despine(left=True) return func(*args, **kwargs) else: return func(*args, **kwargs) return call_w_context
Example #4
Source File: plot.py From graspy with Apache License 2.0 | 5 votes |
def _distplot( data, labels=None, direction="out", title="", context="talk", font_scale=1, figsize=(10, 5), palette="Set1", xlabel="", ylabel="Density", ): plt.figure(figsize=figsize) ax = plt.gca() palette = sns.color_palette(palette) plt_kws = {"cumulative": True} with sns.plotting_context(context=context, font_scale=font_scale): if labels is not None: categories, counts = np.unique(labels, return_counts=True) for i, cat in enumerate(categories): cat_data = data[np.where(labels == cat)] if counts[i] > 1 and cat_data.min() != cat_data.max(): x = np.sort(cat_data) y = np.arange(len(x)) / float(len(x)) plt.plot(x, y, label=cat, color=palette[i]) else: ax.axvline(cat_data[0], label=cat, color=palette[i]) plt.legend() else: if data.min() != data.max(): sns.distplot(data, hist=False, kde_kws=plt_kws) else: ax.axvline(data[0]) plt.title(title) plt.xlabel(xlabel) plt.ylabel(ylabel) return ax
Example #5
Source File: plot_utils.py From jqfactor_analyzer with MIT License | 5 votes |
def plotting_context(context='notebook', font_scale=1.5, rc=None): if rc is None: rc = {} rc_default = {'lines.linewidth': 1.5} for name, val in rc_default.items(): rc.setdefault(name, val) return sns.plotting_context(context=context, font_scale=font_scale, rc=rc)
Example #6
Source File: initialize.py From actionable-recourse with BSD 3-Clause "New" or "Revised" License | 4 votes |
def create_data_summary_plot(data_df, subplot_side_length = 3.0, subplot_font_scale = 0.5, max_title_length = 30): df = pd.DataFrame(data_df) # determine number of plots n_plots = len(data_df.columns) n_cols = int(np.round(np.sqrt(n_plots))) n_rows = int(np.round(n_plots / n_cols)) assert n_cols * n_rows >= n_plots colnames = df.columns.tolist() plot_titles = [c[:max_title_length] for c in colnames] f, axarr = plt.subplots(n_rows, n_cols, figsize=(subplot_side_length * n_rows, subplot_side_length * n_cols), sharex = False, sharey = True) sns.despine(left = True) n = 0 with sns.plotting_context(font_scale = subplot_font_scale): for i in range(n_rows): for j in range(n_cols): ax = axarr[i][j] if n < n_plots: bar_color = 'g' if n == 0 else 'b' vals = df[colnames[n]] unique_vals = np.unique(vals) sns.distplot(a = vals, kde = False, color = bar_color, ax = axarr[i][j], hist_kws = {'edgecolor': "k", 'linewidth': 0.5}) ax.xaxis.label.set_visible(False) ax.text(.5, .9, plot_titles[n], horizontalalignment = 'center', transform = ax.transAxes, fontsize = 10) if len(unique_vals) == 2: ax.set_xticks(unique_vals) n += 1 else: ax.set_visible(False) plt.tight_layout() plt.show() return f, axarr