Skip to content

Instantly share code, notes, and snippets.

@satojkovic
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satojkovic/9391182 to your computer and use it in GitHub Desktop.
Save satojkovic/9391182 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
from collections import Counter
# hist
m = np.asarray([2058, 2059, 2058, 2100, 2100, 2102, 2101, 2058, 2059, 2100])
print sorted(Counter(m).items())
plt.subplot(211)
plt.hist(m, bins=45)
# bar
x = []
y = []
label = []
for k, v in sorted(Counter(m).items()):
x.append(len(y))
y.append(v)
label.append(k)
plt.subplot(212)
plt.bar(x, y, align='center')
plt.xticks(x, label)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment