Created
December 17, 2020 12:58
-
-
Save OhadRubin/6413c6d80bf006408fc61b2a53ea17a6 to your computer and use it in GitHub Desktop.
print a colored distribution in cli
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
import matplotlib.cm as cm | |
from blessed import Terminal | |
def print_dist(prob,cmap=cm.gray): | |
term = Terminal() | |
for i_list in prob.tolist(): | |
result ="" | |
for i in i_list: | |
r,g,b,a = cmap(i,bytes=True) | |
col = term.color_rgb(r,g,b) | |
result += col +'█' | |
print(result+term.normal, flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment