Skip to content

Instantly share code, notes, and snippets.

@adunsmoor
Last active October 11, 2015 15:38
Show Gist options
  • Save adunsmoor/3881296 to your computer and use it in GitHub Desktop.
Save adunsmoor/3881296 to your computer and use it in GitHub Desktop.
Quick and dirty histogram using Matplotlib
# Quick and dirty histogram using Matplotlib
# Reads a file full of numbers and creates a histogram.
import sys
import matplotlib.pyplot as plt
for file in sys.argv[1:]:
with open(file) as f:
values = [float(x) for x in f]
plt.hist(values, bins=100, log=True, label=file)
plt.xlabel('Values')
plt.ylabel('Frequency')
if len(sys.argv) > 1: plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment