2016-12-16 26 views
2

我用下面的代碼創建了一個boxplot,看起來像下面的圖片,我無法弄清楚爲什麼在大西洋海岸和太平洋海岸盒子上面出現一些奇怪的加號標記。爲什麼這些'+'標記顯示出來?在熊貓盒子上出現的奇怪標記

boxplot_2015 = data_2015.boxplot(column = 'LCOE', by = 'Coastal Region', return_type = 'axes') 
plt.title('LCOE by Region') 
plt.suptitle('') 
plt.xlabel('Region') 
plt.ylabel('LCOE ($/MWh)') 
plt.grid(False) 
plt.show() 

enter image description here

+0

那些加號是在一定範圍之外的觀察值。你必須閱讀文檔才能看到盒子的情節。 –

回答

1

這些都是fliers。如果你不喜歡他們用showfliers=False

docs

傳單:代表數據超出晶須(傳單)點。

調整你的代碼

boxplot_2015 = data_2015.boxplot(
    column = 'LCOE', by = 'Coastal Region', 
    return_type = 'axes', showfliers=False) 
plt.title('LCOE by Region') 
plt.suptitle('') 
plt.xlabel('Region') 
plt.ylabel('LCOE ($/MWh)') 
plt.grid(False) 
plt.show() 

示範

df = pd.DataFrame(np.random.randn(1000, 4), columns=list('ABCD')) 

fig, axes = plt.subplots(1, 2) 
df.boxplot(ax=axes[0]) 
axes[0].set_title('With Fliers') 
df.boxplot(ax=axes[1], showfliers=False) 
axes[1].set_title('Without Fliers') 

enter image description here

+0

謝謝piRSquared的深入解釋!我對熊貓和matplotlib還是比較陌生的,所以這對我有很大的幫助。 – ProficientInMath