Reputation: 24774
with python and matplotlib, I can plot a histogram and I can put a text in the histogram area,
import matplotlib.pyplot as plt
import numpy as np
a = np.array([10, 10, 10, 8, 9, 9, 7])
mean = np.mean(a)
fig = plt.figure(figsize=(14, 8))
ax = fig.add_subplot(111)
plt.hist(a, alpha=0.2)
ax.set_ylabel(u'Frequency')
ax.set_xlabel(u'Some data')
ax.xaxis.set_label_coords(0.8, -0.1)
ax.text(mean, 0, '$\mu$\n{}'.format(mean))
plt.show()
how I can put the text under the axis?
Upvotes: 1
Views: 3453
Reputation: 85482
Use a negative value for y
:
ax.text(mean, -0.3, '$\mu$\n{}'.format(mean))
Upvotes: 1