Last active
February 29, 2020 03:43
-
-
Save eigenhombre/9c07852946a9b5294568a9229a9e0c66 to your computer and use it in GitHub Desktop.
plotting numbers from stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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