You can use plot
or vlines
to draw a vertical line, but to draw a vertical line from the bottom to the top of the y axis, axvline
is the probably the simplest function to use. Here’s an example:
In [80]: import numpy as np
In [81]: import matplotlib.pyplot as plt
In [82]: np.random.seed(6789)
In [83]: x = np.random.gamma(4, 0.5, 1000)
In [84]: result = plt.hist(x, bins=20, color="c", edgecolor="k", alpha=0.65)
In [85]: plt.axvline(x.mean(), color="k", linestyle="dashed", linewidth=1)
Out[85]: <matplotlib.lines.Line2D at 0x119758828>
Result: