二维对象阵列的视觉表示

假设我获得了一个对象数组,例如

`array([[ 0 ,  0 , 'g', 'g', 'g'],
        [ 0 ,  0 ,  0 , 'g', 'g'],
        ['d',  0 ,  1 ,  1 , 'g'],
        ['d', 'd',  1 ,  1 , 'g'],
        ['d', 'd', 'd', 'd', 'g']], dtype=object)
`

I want to be able to visually see this as I would for using plt.imshow on a numpy array. More specifically, I would like to see an image where the region with g is some color (maybe yellow), the region with d is some color (maybe green) and maybe a colormap that changes for numeric values 0,1,2,... as the example image below.

enter image description here