Skip to content

Instantly share code, notes, and snippets.

@swateek
Created July 28, 2017 10:17
Show Gist options
  • Save swateek/422ddb850274c07a6fabf825cb1a2f05 to your computer and use it in GitHub Desktop.
Save swateek/422ddb850274c07a6fabf825cb1a2f05 to your computer and use it in GitHub Desktop.
Plotting a Histogram with bucket sizes
import numpy as np
import matplotlib.pyplot as plt
hist, bin_edges = np.histogram([1, 1, 2, 2, 2, 2, 3], bins = range(5))
plt.bar(bin_edges[:-1], hist, width = 1)
plt.xlim(min(bin_edges), max(bin_edges))
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment