Reputation:
Can I please get some help on how I can include the counts on my bar chart. Thank you.
sns.countplot(data['target'])
plt.plot(0, label ="0 = No")
plt.plot(1, label ="1 = Yes")
plt.xlabel("Target")
plt.ylabel("count")
plt.title("Target vrs count")
plt.legend()
plt.show()
Upvotes: 4
Views: 5187
Reputation: 76297
You can use matplotlib.text
:
from matplotlib import pyplot as plt
data = pd.DataFrame({'target': [1, 1, 1, 0, 0]})
sns.countplot(data.target);
for v in [0, 1]:
plt.text(v, (data.target == v).sum(), str((data.target == v).sum()));
Upvotes: 5