2016-06-30 33 views
9

Seaborn stripplot ma funkcję, która umożliwia hue.AttributeError: Nieznana legenda właściwości w seaborn

Korzystając z przykładu z https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.stripplot.html

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) 

enter image description here

W tym przypadku, legenda jest dość mały, pokazując inny odcień dla każdego dnia. Chciałbym jednak usunąć legendę.

Zwykle jeden zawiera parametr legend=False. Jednak dla stripplot, to wydaje się wyjście błędu atrybut:

AttributeError: Unknown property legend 

Czy można usunąć legendę dla stripplots? Jeśli tak, jak to zrobić?

+0

Możliwy duplikat [? Przesuń Seaborn wykresu legendę na inną pozycję] (http://stackoverflow.com/questions/27019079/move-seaborn -plot-legend-to-a-different-position) –

+0

@EliSadoff Trochę jestem wolny: jak całkowicie usunąć legendę? – ShanZhengYang

Odpowiedz

22

Zastosowanie ax.legend_.remove() jak tutaj:

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

Dzięki za to! – ShanZhengYang