1

Does someone knows how in python(matplotlib, pandas_bokeh,...) plot frequency scatter plot with error bars, if it is called like that?
What I want is on y axis to have number of events(counts, instead of value) with the corresponding value in x axes, practically like histogram, but instead of bars, I would like to use dots. And possibly add error bars to mentioned dots.
It would look something like this:enter image description here

Falco Peregrinus
  • 507
  • 2
  • 7
  • 19

1 Answers1

2

Use a combination of numpy.hist and plt.errorbars:

import numpy as np
import matplotlib.pyplot as plt

x = np.random.normal(size=(20000, ))

hist, bin_edges = np.histogram(x, bins=50, density=False)
bin_center = (bin_edges[:-1] + bin_edges[1:])/2

plt.figure()
plt.hist(x, bins=50, density=False)
plt.errorbar(bin_center, hist, yerr=50, fmt='.')
plt.show()

enter image description here

Liris
  • 1,399
  • 3
  • 11
  • 29