Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
Created December 17, 2020 12:58
Show Gist options
  • Save OhadRubin/6413c6d80bf006408fc61b2a53ea17a6 to your computer and use it in GitHub Desktop.
Save OhadRubin/6413c6d80bf006408fc61b2a53ea17a6 to your computer and use it in GitHub Desktop.
print a colored distribution in cli
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