Поэтому, потратив некоторое время, я сам нашел решение, используя numpy.Histogram
и график Bar
.
Оставьте это здесь на случай, если кто-то столкнется с той же проблемой.
def plot_bar_with_outliers(series, name, end):
start = int(series.min())
size = 1
# Making a histogram
largest_value = series.max()
if largest_value > end:
hist = np.histogram(series, bins=list(range(start, end+size, size)) + [largest_value])
else:
hist = np.histogram(series, bins=list(range(start, end+size, size)) + [end+size])
# Adding labels to the chart
labels = []
for i, j in zip(hist[1][0::1], hist[1][1::1]):
if j <= end:
labels.append('{} - {}'.format(i, j))
else:
labels.append('> {}'.format(i))
# Plotting the graph
data = [go.Bar(x=labels,
y=hist[0])]
layout = go.Layout(
title=name
)
fig = go.Figure(data=data, layout=layout)
iplot(fig, filename='basic histogram')
plot_bar_with_outliers(test_df['values'], 'values', end=11)
![enter image description here](https://i.stack.imgur.com/qjpA1.png)