While trying to plot a cumulative distribution function (CDF) using matplotlib's hist
function, the last point goes back to zero. I read some threads explaining that this is because of the histogram-like format, but couldn't find a solution for my case.
Here's my code:
import matplotlib.pyplot as plt
x = [7.845419,7.593756,7.706831,7.256211,7.147965]
fig, ax=plt.subplots()
ax.hist(x, cumulative=True, normed=1, histtype='step', bins=100, label=('Label-1'), lw=2)
ax.grid(True)
ax.legend(loc='upper left')
plt.show()
which produces the following image
As you can see, the stepfunction goes to zero after the last bin of the histogram, which is undesired. How can I change my code so the CDF does not go back to zero?
Thank you