首页 > 解决方案 > 箱线图不显示异常值

问题描述

这是我创建箱线图的功能。但它没有显示异常值。有什么帮助吗?

def box_plot_draw (data, box_colors): 
        #plt.style.use('Solarize_Light2')
        fig, ax = plt.subplots()#figsize=(10, 6))
        fig.canvas.set_window_title('A Boxplot Example')
        fig.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25) # 


    bp = ax.boxplot(data, notch=0, sym='+', vert=1, whis=1.5)  
    plt.setp(bp['boxes'], color='black')                       
    plt.setp(bp['whiskers'], color='black')
    plt.setp(bp['fliers'], color='red', marker='+')
    box_colors = box_colors


    ax.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) #what is which?
    ax.set_axisbelow(True)


    #setting the tile for distribution
    ax.set_title('Comparison of the duration of time for two Distributions')
    ax.set_xlabel('Distribution')
    ax.set_ylabel('Value')

您可以使用此数据测试代码。

np.random.seed(10)
collectn_1 = np.random.normal(100, 10, 200)
collectn_2 = np.random.normal(80, 30, 200)


## combine these different collections into a list    
data_to_plot = [collectn_1, collectn_2]
box_colors = ['black', 'green']    

box_plot_draw (data_to_plot, box_colors)
plt.show()

我正在使用 Jupyter 笔记本,并将样式用于其他功能。但是我没有为这个功能使用任何样式。

标签: pythonmatplotlib

解决方案


推荐阅读