2016-03-30 2 views
6

に特定のボックスに色を割り当てます与えられたカラーパレットを持つ他のすべて?は、私は、おおまかに以下のseaborn.boxplot呼んでいるseaborn.boxplot

enter image description here

+1

あなたは、最小限の完全かつ検証可能な例を提供することができますか? – Chiel

+0

@Chiel seaborn.boxplot docsは、あなたが遊ぶための最小限の例を提供します:http://web.stanford.edu/~mwaskom/software/seaborn/generated/seaborn.boxplot.html – clstaudt

答えて

15

sns.boxplotを使用して作られたボックスは、本当にただmatplotlib.patches.PathPatchオブジェクトです。これらはax.artistsにリストとして格納されています。

したがって、特にax.artistsのインデックスを作成して1つのボックスを選択できます。次に、facecolor,edgecolorおよびlinewidthを他の多くのプロパティの中から設定できます。 (例の一つhereに基づく)例えば

import seaborn as sns 
import matplotlib.pyplot as plt 

sns.set_style("whitegrid") 
tips = sns.load_dataset("tips") 
ax = sns.boxplot(x="day", y="total_bill", hue="smoker", 
       data=tips, palette="Set3") 

# Select which box you want to change  
mybox = ax.artists[2] 

# Change the appearance of that box 
mybox.set_facecolor('red') 
mybox.set_edgecolor('black') 
mybox.set_linewidth(3) 

plt.show() 

enter image description here

関連する問題