'Get specific values of Y-axis on histogram

I graphed 2 histograms on a single plot, how do i get the specific values for each bar? i need to figure out the specific numbers and compare them

x = ['positive','negative','positve','positve','positve','positve','negative']
y = ['negative','positive','positve','negative','positve','positve','positive']

values, bins, patches = plt.hist([x, y], bins=np.arange(3)-0.5, label=['Retold Stories', 'Recalled Stories'],density=True)

plt.legend(loc='upper right')
plt.gca().yaxis.set_major_formatter(PercentFormatter(1))
plt.show()

UPDATE: How do I make the the values on top of the bar into percentages instead of the decimals?

fig, ax = plt.subplots()
x = ['positive','negative','positve','positve','positve','positve','negative']
y = ['negative','positive','positve','negative','positve','positve','positive']

values, bins, patches = plt.hist([x, y], bins=np.arange(3)-0.5, label=['Retold Stories', 'Recalled Stories'],density=True)

plt.legend(loc='upper right')
plt.gca().yaxis.set_major_formatter(PercentFormatter(1))
for container in ax.containers:
ax.bar_label(container)
plt.show()

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source