Это пример кода для добавления «больше или меньше чем».Вы можете изменить значения (v), если> 10 или <-10, затем вручную добавить строку «>» или «<» в конце бункеров.</p>
np.random.seed(123)
fig, ax = plt.subplots(figsize=(8, 5))
v = np.random.randint(low=-15,high=15,size=20)
v_plot = [15 if i > 10 else i for i in v]
v_plot = [-15 if i < -10 else i for i in v_plot]
bins = np.arange(-15,20,5)
plt.hist(np.clip(v_plot, bins[0], bins[-1]),bins=bins)
xlabels = bins[1:].astype(str)
xlabels[-1] = '>' + xlabels[-2]
xlabels[0] = '< ' + xlabels[0]
N_labels = len(xlabels)
plt.xlim([-15, 15])
plt.xticks(5*np.arange(N_labels)-12.5)
ax.set_xticklabels(xlabels)
plt.title('Sample: Greater and less than')
plt.show()
