I'm learning python3 and I'd like to print a matrix/2d-array which is color-coded (CLI). So let's say I'd like to assign each of these integers a certain background color, creating a mosaic-style look.
I've figured out how to fill a matrix of a given size with random integers, but I can't wrap my head around on how to continue from here on to achieve background coloring for each individual entry in the matrix, depending on its value. This is how far I've come:
from random import randint
import numpy as np
def generate():
n = 10
m = 0
map = np.random.randint(4 + 1, size=(n, n))
print(map)
for element in np.nditer(map):
# iterating over each column is probably not the way to go...
generate()
Is there a way to do this? I was thinking of iterating through every column of the matrix and check by several if conditions whether the entry is 0,1,2,3 or 4 and, based on the condition, append that value with a certain background color to a new matrix, but I assume there is a far more elegant way to do this...

