Skip to content

Instantly share code, notes, and snippets.

@amarion35
Forked from amarioncosmo/stdout_plot.py
Created October 11, 2018 17:32
Show Gist options
  • Select an option

  • Save amarion35/9cd07e32f3cb5099f4c249aa3792aaaf to your computer and use it in GitHub Desktop.

Select an option

Save amarion35/9cd07e32f3cb5099f4c249aa3792aaaf to your computer and use it in GitHub Desktop.
matplotlib is for the weaks
def plot(array, width, height):
size = len(array)
y = [array[int(round(k*size/width)):int(round((k+1)*size/width))] for k in range(width)]
y = [np.mean(k) for k in y[5:]] #y[5:] when the firsts values are too big
y = height*(y-np.min(y))/(np.max(y)-np.min(y))
res = np.array(list([list('#'*int(round(y[k]))+' '*int(round(height-y[k]))) for k in range(len(y))]))
res = np.rot90(res, k=1, axes=(0,1))
for r in res:
print(''.join(r))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment