Skip to content

Instantly share code, notes, and snippets.

@eigenhombre
Last active February 29, 2020 03:43
Show Gist options
  • Save eigenhombre/9c07852946a9b5294568a9229a9e0c66 to your computer and use it in GitHub Desktop.
Save eigenhombre/9c07852946a9b5294568a9229a9e0c66 to your computer and use it in GitHub Desktop.
plotting numbers from stdin
#!/usr/bin/env python
import random
import matplotlib.pyplot as plt
import numpy as np
import sys
def histnums(filename, x, nbins=100):
fig, ax = plt.subplots()
ax.hist(np.array(x), bins=nbins, density=True)
plt.savefig(filename)
def readinput():
return [float(x) for x in sys.stdin if x.strip()]
if __name__ == "__main__":
histnums(sys.argv[1], readinput())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment