आप कथा चाहते हैं में
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
# Load the example Titanic dataset
titanic = sns.load_dataset("titanic")
# Draw a nested barplot to show survival for class and sex
fig, ax = plt.subplots()
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted", ax=ax)
sns.despine(ax=ax, left=True)
ax.set_ylabel("survival probability")
l = ax.legend()
l.set_title('Whatever you want')
fig.show()
परिणाम, साजिश अक्ष के बाहर दिखाया जा सकता है के रूप में factorplot
के लिए डिफ़ॉल्ट है, तो आप FacetGrid.add_legend
उपयोग कर सकते हैं (factorplot
रिटर्न एक FacetGrid
उदाहरण)। अन्य तरीकों आप पर
एक बार
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
# Load the example Titanic dataset
titanic = sns.load_dataset("titanic")
# Draw a nested barplot to show survival for class and sex
g = sns.factorplot(x="class", y="survived", hue="sex", data=titanic,
size=6, kind="bar", palette="muted", legend=False)
(g.despine(left=True)
.set_ylabels('survival probability')
.add_legend(title='Whatever you want')
)
आप कोड का उपयोग कर रहे जोड़ने की जरूरत है
FacetGrid
में हर अक्ष के लेबल एडजस्ट करती हैं। – Ali