當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.boxplot方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.boxplot方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.boxplot方法的具體用法?Python pyplot.boxplot怎麽用?Python pyplot.boxplot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.boxplot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: task_3_IQR

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def task_3_IQR(flight_data):
    plot=plt.boxplot(flight_data['Price'],patch_artist=True)
    for median in plot['medians']:
        median.set(color='#fc0004', linewidth=2)
    for flier in plot['fliers']:
        flier.set(marker='+', color='#e7298a')
    for whisker in plot['whiskers']:
        whisker.set(color='#7570b3', linewidth=2)
    for cap in plot['caps']:
        cap.set(color='#7570b3', linewidth=2)
    for box in plot['boxes']:
        box.set(color='#7570b3', linewidth=2)
        box.set(facecolor='#1b9e77')
    plt.matplotlib.pyplot.savefig('task_3_iqr.png')
    clean_data=[]
    for index,row in flight_data.loc[flight_data['Price'].isin(plot['fliers'][0].get_ydata())].iterrows():
        clean_data.append([row['Price'],row['Date_of_Flight']])
    return pd.DataFrame(clean_data, columns=['Price', 'Date_of_Flight']) 
開發者ID:PhoenixDD,項目名稱:Cheapest-Flights-bot,代碼行數:20,代碼來源:Flight Analysis.py

示例2: box_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def box_plot(data, output_directory, output_file_name):
    """
        Plots Box Plots

    Args:
        data (list):  data
        output_drectory(str): location to save graph
        output_file_name(str): name of the image file to be saved

    Returns:
        null
    """
    plt.figure()
    plt.boxplot(data)
    
    plt.legend()
    saver.check_if_dir_exists(output_directory)
    plt.savefig(output_directory + "/" + output_file_name + ".png")
    plt.close() 
開發者ID:prasadtalasila,項目名稱:IRCLogParser,代碼行數:21,代碼來源:vis.py

示例3: plot_boxplots

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def plot_boxplots(self, data_map, title="", xlab="", ylab="", xticks_rotation=0, xticks_fontsize=5):
        """Plot multiple pairs of data arrays.

        :param self: object.
        :param data_map: A dictionary with labels as keys and lists as data values.
        :param title: Figure title.
        :param xlab: X axis label.
        :param ylab: Y axis label.
        :param xticks_rotation: Rotation value for x tick labels.
        :param xticks_fontsize: Fontsize for x tick labels.
        :returns: None
        :rtype: object
        """
        fig = plt.figure()
        plt.boxplot(list(data_map.values()))
        plt.xticks(np.arange(len(data_map)) + 1, data_map.keys(), rotation=xticks_rotation, fontsize=xticks_fontsize)
        self._set_properties_and_close(fig, title, xlab, ylab) 
開發者ID:nanoporetech,項目名稱:wub,代碼行數:19,代碼來源:report.py

示例4: drawBoxPlot_Both_USER

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def drawBoxPlot_Both_USER(app,dr,drILP):
    fig, ax = plt.subplots()
    data_a=dr[dr.app==app].r.values
    data_b=drILP[drILP.app==app].r.values
    ticks = list(np.sort(dr[dr.app==app].user.unique()))
    bpl = plt.boxplot(data_a, positions=np.array(xrange(len(data_a)))*2.0-0.4, sym='', widths=0.6)
    bpI = plt.boxplot(data_b, positions=np.array(xrange(len(data_b)))*2.0+0.4, sym='', widths=0.6)
    set_box_color(bpl, '#5ab4ac') # colors are from http://colorbrewer2.org/
    set_box_color(bpI, '#d8b365')
    # draw temporary red and blue lines and use them to create a legend
    plt.plot([], c='#5ab4ac', label='Partition')
    plt.plot([], c='#d8b365', label='ILP') 
    plt.legend()
    
    plt.xticks(xrange(0, len(ticks) * 2, 2), ticks)
    plt.xlim(-2, len(ticks)*2)
    #plt.ylim(0, 10000)
#    plt.ylim(00, 1000)
    ax.set_title('App: %i'%app)
    ax.set_ylabel('Time Response')
    ax.set_xlabel('User')
    plt.tight_layout()
    plt.savefig(pathSimple+"app%i.png"%app) 
開發者ID:acsicuib,項目名稱:YAFS,代碼行數:25,代碼來源:analyse_results2.py

示例5: drawBoxPlot_App

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def drawBoxPlot_App(dar,darILP,labeldar="Partition",labelILP="ILP"):
    fig, ax = plt.subplots()
    #This is not work :/
    #data_a = dr.groupby(["app"]).agg({"values": lambda x: list(x.sum())})
    data_a=dar.r.values
    data_b=darILP.r.values
    ticks = list(np.sort(dar.app.unique()))
      
    bpl = plt.boxplot(data_a, positions=np.array(xrange(len(data_a)))*2.0-0.4, sym='', widths=0.6)
    bpI = plt.boxplot(data_b, positions=np.array(xrange(len(data_b)))*2.0+0.4, sym='', widths=0.6)
    set_box_color(bpl, '#5ab4ac') # colors are from http://colorbrewer2.org/
    set_box_color(bpI, '#d8b365')
    # draw temporary red and blue lines and use them to create a legend
    plt.plot([], c='#5ab4ac', label=labeldar)
    plt.plot([], c='#d8b365', label=labelILP) 
    plt.legend()
    
    plt.xticks(xrange(0, len(ticks) * 2, 2), ticks)
    plt.xlim(-2, len(ticks)*2)
    #plt.ylim(50, 400)
    #plt.ylim(0, 10000)
    ax.set_title('All Apps')
    ax.set_ylabel('Time Response')
    ax.set_xlabel('App')
    plt.tight_layout() 
開發者ID:acsicuib,項目名稱:YAFS,代碼行數:27,代碼來源:analyse_results2.py

示例6: drawBoxPlot_Both_USER_ax

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def drawBoxPlot_Both_USER_ax(app,dr,drILP,ax):
    data_a=dr[dr.app==app].r.values
    data_b=drILP[drILP.app==app].r.values
    ticks = list(np.sort(dr[dr.app==app].user.unique()))
    bpl = ax.boxplot(data_a, positions=np.array(xrange(len(data_a)))*2.0-0.4, sym='', widths=0.55,
                     whiskerprops = dict(linewidth=2),
                    boxprops = dict(linewidth=2),
                     capprops = dict(linewidth=2),
                    medianprops = dict(linewidth=2))
    bpI = ax.boxplot(data_b, positions=np.array(xrange(len(data_b)))*2.0+0.4, sym='', widths=0.55,
                        whiskerprops = dict(linewidth=2),
                    boxprops = dict(linewidth=2),
                     capprops = dict(linewidth=2),
                    medianprops = dict(linewidth=2))
    set_box_color(bpl, '#a6bddb')
    set_box_color(bpI, '#e34a33')
    ax.get_xaxis().set_ticks(xrange(0, len(ticks) * 2, 2))
    ax.set_xticklabels(ticks)
    ax.set_xlim(-2, len(ticks)*2)
    ax.plot([], c='#a6bddb', label="Partition",linewidth=3)
    ax.plot([], c='#e34a33', label="ILP",linewidth=3) 
開發者ID:acsicuib,項目名稱:YAFS,代碼行數:23,代碼來源:analyse_results_debug.py

示例7: plot_weight_distribution

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def plot_weight_distribution(path, model):
    parameters = model.get_weights()
    weights = parameters[0::2]
    biases = parameters[1::2]

    plt.figure(figsize=(15, 10))
    plt.boxplot([np.ravel(w) for w in weights], whis=15)
    plt.xlabel("Layer index")
    plt.ylabel("Weight value")
    plt.savefig(os.path.join(path, 'weight_distribution'))

    plt.figure(figsize=(15, 10))
    plt.boxplot([np.ravel(b) for b in biases])
    plt.xlabel("Layer index")
    plt.ylabel("Bias value")
    plt.savefig(os.path.join(path, 'bias_distribution')) 
開發者ID:NeuromorphicProcessorProject,項目名稱:snn_toolbox,代碼行數:18,代碼來源:plotting.py

示例8: _boxplot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def _boxplot(self, plot_kwargs=None, figure_kwargs=None, **kwargs):
        """
        Function to create a boxplot and push it

        Parameters
        ----------
        plot_kwargs : dict
            the arguments for plotting
        figure_kwargs : dict
            the arguments to actually create the figure
        **kwargs :
            additional keyword arguments for pushing the created figure to the
            logging writer

        """
        if plot_kwargs is None:
            plot_kwargs = {}
        if figure_kwargs is None:
            figure_kwargs = {}
        with self.FigureManager(self._figure, figure_kwargs, kwargs):
            from matplotlib.pyplot import boxplot
            boxplot(**plot_kwargs) 
開發者ID:delira-dev,項目名稱:delira,代碼行數:24,代碼來源:base_backend.py

示例9: boxplot_viz

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def boxplot_viz(clean_df, target):
    clean_df = clean_df[target]
    models = pd.unique(clean_df.index.values)
    data_arr = np.array([clean_df[m].values for m in models]).T
    base_colors = [hsl2hex(c) for c in color_scale((0., 0.8, 0.6), (0.8, 0.8, 0.6), len(models))]
    plt.figure(figsize=(7, 3.5))
    title_str = "Raw Per Model {} Comparison ({})".format('Classification' if target=='F1_SCORE' else 'Regression', target)
    plt.title(title_str, size=12)
    bplot = plt.boxplot(data_arr, vert=False, patch_artist=True, notch=True, labels="    ", positions=list(reversed(range(1, len(models)+1))))

    for p, c in zip(bplot['boxes'], base_colors):
        p.set_facecolor(c)

    plt.legend(bplot['boxes'], models, loc='lower left', prop={'size': 8}, fancybox=True, framealpha=0.6)
    plt.setp(bplot['fliers'], markeredgecolor='grey')
    plt.setp(bplot['medians'], color='black')

    # plt.show()
    plt.savefig('figures/RawDataBoxPlot{}.pdf'.format(target), dpi=plt.gcf().dpi, transparent=True) 
開發者ID:georgianpartners,項目名稱:automl_benchmark,代碼行數:21,代碼來源:run_analysis.py

示例10: createBoxplotsFromColumns

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def createBoxplotsFromColumns(title,param, param1):

    plt.title(title)
    plt.boxplot([param,param1])

    plt.savefig('boxplots/boxplot:%s.png' % title,dpi=300)
    plt.gcf().clear() 
開發者ID:SalikLP,項目名稱:classification-of-encrypted-traffic,代碼行數:9,代碼來源:data_exploration.py

示例11: plotAlphaDiversities

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def plotAlphaDiversities(self, alphaDiversityFile, figure_filename):
        # Take an alpha diversity file and create a box plot
        with open(alphaDiversityFile,'r') as fid:
            all_lines = fid.readlines()
            alpha_diversities = [float(line.split()[1]) for line in all_lines[1:]]
            sampleIDs = [line.split()[0] for line in all_lines[1:]]
            figure()
            plt.boxplot(alpha_diversities)
            plt.xlabel('Sample category')
            plt.ylabel('Alpha diversity')
            plt.savefig(figure_filename) 
開發者ID:thomasgurry,項目名稱:amplicon_sequencing_pipeline,代碼行數:13,代碼來源:AutoPlot.py

示例12: plot_prob_cl_box

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def plot_prob_cl_box(prob_cl_mapping_list, plot_outliers=False):
    ks = prob_cl_mapping_list.keys()
    ks.sort()
    for i, classname in enumerate(ks):
        v = prob_cl_mapping_list[classname]
        data = [[], [], [], []]
        labels = ['0.6~0.7', '0.7~0.8', '0.8~0.9', '0.9~1.0']
        prob_list = v[0]
        cl_list = v[1]
        for cl, prob in zip(cl_list, prob_list):
            if 0.6 <= cl < 0.7:
                ind = 0
            elif 0.7 <= cl < 0.8:
                ind = 1
            elif 0.8 <= cl < 0.9:
                ind = 2
            elif 0.9 <= cl <= 1.0:
                ind = 3
            else:
                raise Exception("invalid CL: %.3f" % cl)
            data[ind].append(prob)
        ax = plt.subplot(3, 2, i + 1)
        if (plot_outliers):
            symb = '+'
        else:
            symb = ''
        plt.boxplot(data, labels=labels, sym=symb)
        plt.xlabel('Consensus level')
        plt.grid(True, linestyle='-', which='major', color='lightgrey',
               alpha=0.5, axis='y')
        if (i % 2 == 0):
            #plt.ylabel('Classification probability')
            plt.ylabel('Probability')
        # if (not plot_outliers):
        #     plt.ylim([0.6, 1.0])
        ax.set_title('%s' % classname.replace('_', 'C_') + 'P')
    #plt.suptitle('Probability vs. Consensus level')
    plt.tight_layout(h_pad=0.0)
    plt.show() 
開發者ID:chenwuperth,項目名稱:rgz_rcnn,代碼行數:41,代碼來源:prob_vs_cl.py

示例13: drawBoxPlot_User_App

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def drawBoxPlot_User_App(dr,app):
    fig, ax = plt.subplots()
    ax.boxplot(dr[dr.app==app]["r"].values)
    #TODO ILP CHANGE POSITION 
    ax.set_xticklabels(dr[dr.app==app]["user"].values)
    ax.set_title('App: %i'%app)
    ax.set_ylabel('Time Response')
    ax.set_xlabel('User')
    plt.show() 
開發者ID:acsicuib,項目名稱:YAFS,代碼行數:11,代碼來源:analyse_results2.py

示例14: drawBoxPlot_Both_USER_ax

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def drawBoxPlot_Both_USER_ax(app,dr,drILP,ax):
    data_a=dr[dr.app==app].r.values
    data_b=drILP[drILP.app==app].r.values
    ticks = list(np.sort(dr[dr.app==app].user.unique()))
    bpl = ax.boxplot(data_a, positions=np.array(xrange(len(data_a)))*2.0-0.4, sym='', widths=0.6)
    bpI = ax.boxplot(data_b, positions=np.array(xrange(len(data_b)))*2.0+0.4, sym='', widths=0.6)
    set_box_color(bpl, '#5ab4ac')
    set_box_color(bpI, '#d8b365')
    ax.get_xaxis().set_ticks(xrange(0, len(ticks) * 2, 2))
    ax.set_xticklabels(ticks)
    ax.set_xlim(-2, len(ticks)*2)
    ax.plot([], c='#5ab4ac', label="Partition")
    ax.plot([], c='#d8b365', label="ILP") 
開發者ID:acsicuib,項目名稱:YAFS,代碼行數:15,代碼來源:analyse_results2.py

示例15: after_training

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import boxplot [as 別名]
def after_training(self, runner, training_stats: TrainingStatistics):
        import matplotlib.pyplot as plt

        if len(training_stats.train_summaries) > 0 and (len(training_stats.train_summaries[0].time_used_inference) == 0
                and len(training_stats.train_summaries[0].time_used_optimizing) == 0):
            raise ValueError('To generate box-plots, please train with the '
                             'Trainer object with collect_all_times=True')
        
        inference_test_data = [s.time_used_inference for s in training_stats.test_summaries]
        optimizing_time_train = [s.time_used_optimizing for s in training_stats.train_summaries]

        plt.figure()
        plt.title('Time used for inference')
        plt.xlabel('Epoch')
        plt.ylabel('time used')
        plt.boxplot(inference_test_data, 1, '')
        plt.savefig(self.path + "_inference_test")
        print('Box plot written to: {}.png'.format(self.path + "_inference_test"))
        plt.close()

        plt.figure()
        plt.title('Time used for optimization (inference + gradient update)')
        plt.xlabel('Epoch')
        plt.ylabel('time used')
        plt.boxplot(optimizing_time_train, 1, '')
        plt.savefig(self.path + "_optimizing_train")
        print('Box plot written to: {}.png'.format(self.path + "_optimizing_train"))
        plt.close() 
開發者ID:deep500,項目名稱:deep500,代碼行數:30,代碼來源:summary_boxplots.py


注:本文中的matplotlib.pyplot.boxplot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。