2016-02-29 131 views
0

我正在使用matplotlib 1.4.3版本,我想製作一個小提琴圖,我想顯示平均值和中位數,這很容易實現,但我想標記平均數和中位數,因此可以通過改變其中一個的顏色和/或形狀來輕鬆區分它們,但是在文檔中我看不到任何允許的內容。Matplotlib用顏色或形狀區分平均值和中位數

Anyhelp將不勝感激。

violinplot(x, showmeans=True, showmedians=False, widths=1.0, showextrema=False) 

例Violinplot用的手段和中位數:

回答

4

提示:尋找一個方法的文檔字符串時,切勿錯過Returns部分。

data = np.random.weibull(1.5, size=(1000, 3)) 
r = plt.violinplot(dataset=data, showmeans=True, showmedians=True, 
        widths=1.0, showextrema=False) 
r['cmeans'].set_color('b') 
r['cmedians'].set_color('g') 

enter image description here

+0

非常感謝,該代碼的工作一個魅力! –