当前位置: 首页>>代码示例>>Python>>正文


Python seaborn.boxplot方法代码示例

本文整理汇总了Python中seaborn.boxplot方法的典型用法代码示例。如果您正苦于以下问题:Python seaborn.boxplot方法的具体用法?Python seaborn.boxplot怎么用?Python seaborn.boxplot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在seaborn的用法示例。


在下文中一共展示了seaborn.boxplot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: boxplot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def boxplot(self, column, **kwargs):
        """
        Generate boxplots for a given column in all assets.

        Parameters:
            - column: The name of the column to visualize.
            - kwargs: Additional keyword arguments to pass down
                      to the plotting function.

        Returns:
            A matplotlib Axes object.
        """
        return sns.boxplot(
            x=self.group_by,
            y=column,
            data=self.data,
            **kwargs
        ) 
开发者ID:stefmolin,项目名称:stock-analysis,代码行数:20,代码来源:stock_visualizer.py

示例2: boxplot_metrics

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def boxplot_metrics(df, eval_dir):
    """
    Create summary boxplots of all geometric measures.

    :param df:
    :param eval_dir:
    :return:
    """

    boxplots_file = os.path.join(eval_dir, 'boxplots.eps')

    fig, axes = plt.subplots(3, 1)
    fig.set_figheight(14)
    fig.set_figwidth(7)

    sns.boxplot(x='struc', y='dice', hue='phase', data=df, palette="PRGn", ax=axes[0])
    sns.boxplot(x='struc', y='hd', hue='phase', data=df, palette="PRGn", ax=axes[1])
    sns.boxplot(x='struc', y='assd', hue='phase', data=df, palette="PRGn", ax=axes[2])

    plt.savefig(boxplots_file)
    plt.close()

    return 0 
开发者ID:baumgach,项目名称:acdc_segmenter,代码行数:25,代码来源:metrics_acdc.py

示例3: bar_box_violin_dot_plots

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def bar_box_violin_dot_plots(data, category_col, numeric_col, axes, file_name=None):
    sns.barplot(category_col, numeric_col, data=data, ax=axes[0])
    sns.boxplot(
        category_col, numeric_col, data=data[data[numeric_col].notnull()], ax=axes[2]
    )
    sns.violinplot(
        category_col,
        numeric_col,
        data=data,
        kind="violin",
        inner="quartile",
        scale="count",
        split=True,
        ax=axes[3],
    )
    sns.stripplot(category_col, numeric_col, data=data, jitter=True, ax=axes[1])
    sns.despine(left=True) 
开发者ID:eyadsibai,项目名称:brute-force-plotter,代码行数:19,代码来源:brute_force_plotter.py

示例4: plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot(params_dir):
    model_dirs = [name for name in os.listdir(params_dir)
                  if os.path.isdir(os.path.join(params_dir, name))]

    df = defaultdict(list)
    for model_dir in model_dirs:
        df[re.sub('_bin_scaled_mono_True_ratio', '', model_dir)] = [
            dd.io.load(path)['best_epoch']['validate_objective']
            for path in glob.glob(os.path.join(
                params_dir, model_dir) + '/*.h5')]

    df = pd.DataFrame(dict([(k, pd.Series(v)) for k, v in df.iteritems()]))
    df.to_csv(os.path.basename(os.path.normpath(params_dir)))
    plt.figure(figsize=(16, 4), dpi=300)
    g = sns.boxplot(df)
    g.set_xticklabels(df.columns, rotation=45)
    plt.tight_layout()
    plt.savefig('{}_errors_box_plot.png'.format(
        os.path.join(IMAGES_DIRECTORY,
                     os.path.basename(os.path.normpath(params_dir))))) 
开发者ID:rafaelvalle,项目名称:MDI,代码行数:22,代码来源:plot_errors_boxplot.py

示例5: boxplot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def boxplot(self, fig_width: Number, fig_height: Number = None):
        """
        Creates a (horizontal) box plot comparing all single object for a given property.

        :param fig_width: width of the figure in cm
        :param fig_height: height of the figure in cm, if None it is calculated from the figure width using the
                           aesthetic ratio
        """
        import seaborn as sns
        import matplotlib.pyplot as plt
        self.reset_plt()
        if fig_height is None:
            fig_height = self._height_for_width(fig_width)
        self._fig = plt.figure(figsize=self._fig_size_cm_to_inch(fig_width, fig_height))
        df = self.get_data_frame()
        sns.boxplot(data=df, orient="h") 
开发者ID:parttimenerd,项目名称:temci,代码行数:18,代码来源:stats.py

示例6: BoxPlot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def BoxPlot(self, feature):		
		fig, ax = plt.subplots()
		ax = sns.boxplot(y=self.df[feature], ax=ax)
		box = ax.artists[0]
		indices = random.sample(range(len(self.SelectedColors)), 2)
		colors=[self.SelectedColors[i] for i in sorted(indices)]
		box.set_facecolor(colors[0])
		box.set_edgecolor(colors[1])
		sns.despine(offset=10, trim=True)
		this_dir, this_filename = os.path.split(__file__)
		OutFileName = os.path.join(this_dir, 'HTMLTemplate/dist/output/'+feature + '.png')
		if platform.system() =='Linux':
			OutFileName = os.path.join(this_dir, 'HTMLTemplate/dist/output/' + feature + '.png')
		plt.savefig(OutFileName)
		
		return OutFileName 
开发者ID:exploripy,项目名称:exploripy,代码行数:18,代码来源:TargetAnalysisContinuous.py

示例7: BoxPlot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def BoxPlot(self,var):

		start = time.time()
		fig, ax = plt.subplots()
		ax = sns.boxplot(y=self.df[var], ax=ax)
		box = ax.artists[0]
		indices = random.sample(range(len(self.SelectedColors)), 2)
		colors=[self.SelectedColors[i] for i in sorted(indices)]
		box.set_facecolor(colors[0])
		box.set_edgecolor(colors[1])
		sns.despine(offset=10, trim=True)
		
		
		this_dir, this_filename = os.path.split(__file__)
		OutFileName = os.path.join(this_dir, 'HTMLTemplate/dist/output/'+var + '.png')
		
		plt.savefig(OutFileName)
		end = time.time()
		if self.debug == 'YES':
			print('BoxPlot',end-start)
		
		return OutFileName 
开发者ID:exploripy,项目名称:exploripy,代码行数:24,代码来源:EDA.py

示例8: BoxPlot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def BoxPlot(self, feature):		
		fig, ax = plt.subplots()
		ax = sns.boxplot(y=self.df[feature], ax=ax)
		box = ax.artists[0]
		indices = random.sample(range(len(self.SelectedColors)), 2)
		colors=[self.SelectedColors[i] for i in sorted(indices)]
		box.set_facecolor(colors[0])
		box.set_edgecolor(colors[1])
		sns.despine(offset=10, trim=True)
		this_dir, this_filename = os.path.split(__file__)
		OutFileName = os.path.join(this_dir, 'HTMLTemplate/dist/output/'+feature + '.png')
		if platform.system() == 'Linux':
			out_filename = os.path.join(this_dir, 'ExploriPy/HTMLTemplate/dist/output/'+feature + '.png')
		plt.savefig(OutFileName)
		
		return OutFileName 
开发者ID:exploripy,项目名称:exploripy,代码行数:18,代码来源:TargetAnalysisCategorical.py

示例9: plot_change_by_pos

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot_change_by_pos(diffs_by_context,plottype='box'):
    fig = plt.figure(figsize=(6,4))
    changes_by_position = {'position':[],'base':[],'diff':[]}
    for lab in diffs_by_context:
        for context in diffs_by_context[lab]:
            for entry in diffs_by_context[lab][context]:
                for pos,diff in enumerate(entry[:-1]):
                    changes_by_position['position'].append(pos+1)
                    changes_by_position['base'].append(lab)
                    changes_by_position['diff'].append(diff)
    dPos = pd.DataFrame(changes_by_position)
    if plottype == 'box':
        sns.boxplot(x="position", y="diff", hue="base", data=dPos, palette=[cols[base],cols[methbase]])
    elif plottype == 'violin':
        sns.violinplot(x="position",y="diff", hue="base", data=dPos, palette=[cols[base],cols[methbase]])
    sns.despine(trim=False)
    plt.xlabel('Adenine Position in 6-mer')
    plt.ylabel('Measured - Expected Current (pA)')
    plt.ylim([-20,20])
    plt.legend(title='',loc='upper center', bbox_to_anchor=(0.5, 1.05),
          ncol=3, fancybox=True)
    plt.savefig('change_by_position_box.pdf',transparent=True,dpi=500, bbox_inches='tight') 
开发者ID:al-mcintyre,项目名称:mCaller,代码行数:24,代码来源:plotlib.py

示例10: plot_scores

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot_scores(self):

        matchScores = []
        nonMatchScores = []

        for i in self.bills.keys():
            for j in self.bills.keys():

                if (i,j) not in self.results or self.results[(i,j)]['score'] == 0:
                    #ignore if score zero because url is broken
                    pass
                elif i < j and self.results[(i,j)]['match']:
                    matchScores.append(min(self.results[(i,j)]['score'],200))
                else:
                    nonMatchScores.append(min(self.results[(i,j)]['score'],200))

        bins = np.linspace(min(nonMatchScores + matchScores), max(nonMatchScores + matchScores), 100)
        plt.hist(nonMatchScores, bins, alpha=0.5, label='Non-Matches')
        plt.hist(matchScores, bins, alpha=0.5, label='Matches')
        plt.legend(loc='upper right')
        plt.xlabel('Alignment Score')
        plt.ylabel('Number of Bill Pairs')
        plt.title('Distribution of Alignment Scores')
        plt.show()

        #make boxplot
        data_to_plot = [matchScores, nonMatchScores]
        fig = plt.figure(1, figsize=(9, 6))
        ax = fig.add_subplot(111)
        bp = ax.boxplot(data_to_plot)
        ax.set_xticklabels(['Match Scores', 'Non-Match Scores'])
        fig.show() 
开发者ID:dssg,项目名称:policy_diffusion,代码行数:34,代码来源:alignment_evaluation.py

示例11: plot_num_matches

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot_num_matches(self):

        matchScores = []
        nonMatchScores = []

        for i in self.bills.keys():
            for j in self.bills.keys():

                if self.scores[i,j] == 0:
                    #ignore if score zero because url is broken
                    pass
                elif i < j and self.results[(i,j)]['match']:
                    matchScores.append(min(self.results[(i,j)]['features'][0]['num_matches'],200))
                else:
                    nonMatchScores.append(min(self.results[(i,j)]['features'][0]['num_matches'],200))

        bins = np.linspace(min(nonMatchScores + matchScores), max(nonMatchScores + matchScores), 100)
        plt.hist(nonMatchScores, bins, alpha=0.5, label='Non-Matches')
        plt.hist(matchScores, bins, alpha=0.5, label='Matches')
        plt.legend(loc='upper right')
        plt.xlabel('Alignment Score')
        plt.ylabel('Number of Bill Pairs')
        plt.title('Distribution of Alignment Scores')
        plt.show()

        #make boxplot
        data_to_plot = [matchScores, nonMatchScores]
        fig = plt.figure(1, figsize=(9, 6))
        ax = fig.add_subplot(111)
        bp = ax.boxplot(data_to_plot)
        ax.set_xticklabels(['Match Scores', 'Non-Match Scores'])
        fig.show() 
开发者ID:dssg,项目名称:policy_diffusion,代码行数:34,代码来源:alignment_evaluation.py

示例12: plot_grid

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot_grid(self):

        self._create_grid_df()

        df = self.grid_df
        #make maximum possible 500
        df.loc[df['score']>500,'score'] = 500

        #match plot
        df_match = df[(df['mismatch_score'] == -2) & (df['gap_score'] == -1)]

        g = sns.FacetGrid(df_match, col="match_score")
        g = g.map(sns.boxplot, "match", "score")
        sns.plt.ylim(0,400)
        sns.plt.show()

        #mismatch plot
        df_mismatch = df[(df['match_score'] == 3) & (df['gap_score'] == -1)]

        g = sns.FacetGrid(df_mismatch, col="mismatch_score")
        g = g.map(sns.boxplot, "match", "score")
        sns.plt.ylim(0,400)
        sns.plt.show()

        #gap plot
        df_gap = df[(df['match_score'] == 3) & (df['mismatch_score'] == -2)]

        g = sns.FacetGrid(df_gap, col="gap_score")
        g = g.map(sns.boxplot, "match", "score")
        sns.plt.ylim(0,400)
        sns.plt.show() 
开发者ID:dssg,项目名称:policy_diffusion,代码行数:33,代码来源:alignment_evaluation.py

示例13: plot_null_feature_importance_distributions

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def plot_null_feature_importance_distributions(null_distributions: Mapping[int, List[float]], ax=None) -> None:
    if ax is None:
        _, ax = plt.subplots(1, 1)
    df = pd.DataFrame(null_distributions)
    df = pd.DataFrame(df.unstack()).reset_index().drop("level_1", axis=1)
    df.columns = ["variable", "p"]
    sns.boxplot(x="variable", y="p", data=df, ax=ax)
    ax.set_title("Null Feature Importance Distribution")
    return ax 
开发者ID:JakeColtman,项目名称:bartpy,代码行数:11,代码来源:features.py

示例14: visualize_feature_boxplot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def visualize_feature_boxplot(X,y,selected_feature,features):
	"""
	Visualize the boxplot of a feature

	Keyword arguments:
	X -- The feature vectors
	y -- The target vector
	selected_feature -- The desired feature to obtain the histogram
	features -- Vector of feature names (X1 to XN)
	"""

	#create data
	joint_data=np.column_stack((X,y))
	column_names=features

	#create dataframe
	df=pd.DataFrame(data=joint_data,columns=column_names)

	# palette = sea.hls_palette()
	splot=sea.boxplot(data=df,x='Y',y=selected_feature,hue="Y",palette="husl")
	plt.title('BoxPlot Distribution of '+selected_feature)

	#save fig
	output_dir = "img"
	save_fig(output_dir,'{}/{}_boxplot.png'.format(output_dir,selected_feature))
	# plt.show() 
开发者ID:alexpnt,项目名称:default-credit-card-prediction,代码行数:28,代码来源:visualization.py

示例15: accuracy_results_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import boxplot [as 别名]
def accuracy_results_plot(data_path):
    data = pd.read_csv(data_path,index_col=0)
    sns.boxplot(data=data)
    sns.set(rc={"figure.figsize": (9, 6)})
    ax = sns.boxplot( data=data)
    ax.set_xlabel(x_label,fontsize=15)
    ax.set_ylabel(y_label,fontsize=15)
    plt.show() 
开发者ID:gumpy-bci,项目名称:gumpy,代码行数:10,代码来源:plot.py


注:本文中的seaborn.boxplot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。