Skip to content

Instantly share code, notes, and snippets.

@sksq96
Last active December 2, 2019 16:53
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 sksq96/197159c0058164dfe86da4ccb1684d39 to your computer and use it in GitHub Desktop.
Save sksq96/197159c0058164dfe86da4ccb1684d39 to your computer and use it in GitHub Desktop.
Plot histogram from list
def hist(d, count=True):
import matplotlib.pyplot as plt
if count:
d = list(map(len, d))
n, bins, patches = plt.hist(x=d, bins='auto', color='#0504aa', alpha=0.7, rwidth=0.85)
plt.grid(axis='y', alpha=0.75)
plt.xlabel('Value')
plt.ylabel('Frequency')
maxfreq = n.max()
plt.ylim(ymax=np.ceil(maxfreq / 10) * 10 if maxfreq % 10 else maxfreq + 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment