Вот решение, которое делает именно то, что вы упомянули: наложите гистограмму на график рассеяния.
Конечно, вы можете дополнительно поиграть, чтобы настроить график: название графика, метки оси, цвета, ширина,форма маркера графика рассеяния ...
import matplotlib.pyplot as plt
np.random.seed(123)
w = 0.8 # bar width
x = [1, 2] # x-coordinates of your bars
colors = [(0, 0, 1, 1), (1, 0, 0, 1)] # corresponding colors
y = [np.random.random(30) * 2 + 5, # data series
np.random.random(10) * 3 + 8]
fig, ax = plt.subplots()
ax.bar(x,
height=[np.mean(yi) for yi in y],
yerr=[np.std(yi) for yi in y], # error bars
capsize=12, # error bar cap width in points
width=w, # bar width
tick_label=["control", "test"],
color=(0,0,0,0), # face color transparent
edgecolor=colors,
#ecolor=colors, # error bar colors; setting this raises an error for whatever reason.
)
for i in range(len(x)):
# distribute scatter randomly across whole width of bar
ax.scatter(x[i] + np.random.random(y[i].size) * w - w / 2, y[i], color=colors[i])
plt.show()
Это даст этот график
