

There are so many points in data that the effect is not visible without a zoom, but the very last point at the total count does matter when the data contains only a few points.Īfter conclusive discussion with I wanted to post my solution (upper left) using a random Gaussian sample as a summary:Ĭalculates the normal distribution's probability density Plt.step(np.concatenate(, sorted_data]]), This can be achieved with: plt.step(np.concatenate(]]), PS: As SebastianRaschka noted, the very last point should ideally show the total count (instead of the total count-1). You can see that it is more ragged than the output of EnricoGiampieri's answer, but this one is the real histogram (instead of being an approximate, fuzzier version of it).

Plt.step(sorted_data, np.arange(sorted_data.size)) # From the number of data points-1 to 0įurthermore, a more appropriate plot style is indeed plt.step() instead of plt.plot(), since the data is in discrete locations. Plt.step(sorted_data, np.arange(sorted_data.size)) # From 0 to the number of data points-1 Sorted_data = np.sort(data) # Or data.sort(), if data can be modified This shorter and simpler solution looks like this: import numpy as np

Using histograms is really unnecessarily heavy and imprecise (the binning makes the data fuzzy): you can just sort all the x values: the index of each value is the number of values that are smaller.
