ax.imshow(np.arange(n).reshape(1, n), cmap=mpl.colors.ListedColormap(list(
    pal)), interpolation='nearest', aspect='auto')
ax.set_xticks(np.arange(n) - 0.5)
Displaying matrix-like image with RGB-colored cells in matplotlib