2016-06-30 14 views
9

seabornのstripplotにはを許可する関数があります。例を使用AttributeError:seabornの不明なプロパティの凡例

この場合

enter image description here

import seaborn as sns 
sns.set_style("whitegrid") 
tips = sns.load_dataset("tips") 
ax = sns.stripplot(x=tips["total_bill"]) 
ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True) 
https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.stripplot.htmlから、凡例は、それぞれの日の異なる色合いを示す、非常に小さいです。しかし、私は伝説を削除したいと思います。

通常、パラメータにはlegend=Falseが含まれます。しかし、stripplotのために、これは出力に属性のエラーが表示されます。

AttributeError: Unknown property legend 

1はstripplotsの凡例を削除できますか?もしそうなら、どのようにこれを行うのですか?

+0

[?別の位置にseabornプロット凡例を移動]の可能複製(http://stackoverflow.com/questions/27019079/move-seaborn -plot-legend-to-a-different-position) –

+0

@EliSadoff私は少し遅いです:あなたは完全に伝説を削除しますか? – ShanZhengYang

答えて

22

使用ax.legend_.remove()ここのように:

import seaborn as sns 
import matplotlib.pylab as plt 
sns.set_style("whitegrid") 
tips = sns.load_dataset("tips") 
ax = sns.stripplot(x="sex", y="total_bill", hue="day", data=tips, jitter=True) 

# remove legend from axis 'ax' 
ax.legend_.remove() 

plt.show() 

enter image description here

+0

ありがとう! – ShanZhengYang

関連する問題