Last active
July 13, 2024 15:05
-
-
Save tammoippen/4474e838e969bf177155231ebba52386 to your computer and use it in GitHub Desktop.
Draw a crappy text-mode histogram of an array (python 3)
This file contains hidden or 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
import numpy as np | |
def crappyhist(a, bins=50, width=140): | |
h, b = np.histogram(a, bins) | |
for i in range (0, bins): | |
print('{:12.5f} | {:{width}s} {}'.format( | |
b[i], | |
'#'*int(width*h[i]/np.amax(h)), | |
h[i], | |
width=width)) | |
print('{:12.5f} |'.format(b[bins])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modified from: http://kevinastraight.x10host.com/2013/12/28/python-histograms-from-the-console/
Output something like: