Skip to content

Instantly share code, notes, and snippets.

@heathhenley
Last active August 28, 2019 22:12
Show Gist options
  • Save heathhenley/2237984e43d5e751ce8d9b45d892a812 to your computer and use it in GitHub Desktop.
Save heathhenley/2237984e43d5e751ce8d9b45d892a812 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
x = np.random.rand(10)
_, _, patches = plt.hist(x, bins=3)
labels = ["label%d" % i for i in range(len(patches))]
for rect, label in zip(patches, labels):
height = rect.get_height()
plt.gca().text(rect.get_x() + rect.get_width() / 2, height, label,
ha='center', va='bottom')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment