Вы можете сгенерировать гистограмму, используя numpy.histogram()
, а затем построить ее, используя Axes.bar()
.Тики можно затем отрегулировать с помощью Axes.set_ticklabels()
.Вот пример:
import numpy as np
from matplotlib import pyplot as plt
#some fake data:
data = np.random.normal(70,20,[100])
#the histogram
dist, edges = np.histogram(data,bins=[0,40,60,65,70,75,80])
#the plot
fig,ax = plt.subplots()
ax.bar(
np.arange(dist.shape[0]), dist, width=1, align = 'edge',
color = [1,0,0,0.5], edgecolor=[1,0,0,1], lw = 2,
)
ax.set_xticks(np.arange(edges.shape[0]))
ax.set_xticklabels(edges)
plt.show()
Все выглядит примерно так:
![result of the above code](https://i.stack.imgur.com/JuDjJ.png)
Надеюсь, это поможет.