from matplotlib.colors import ListedColormap

cm3 = ListedColormap(['#0000aa', '#ff2020', '#50ff50'])
cm2 = ListedColormap(['#0000aa', '#ff2020'])

[((3, 6, 3, 55), 'matplotlib.colors.ListedColormap', 'ListedColormap', ({(3, 21, 3, 54): "['#0000aa', '#ff2020', '#50ff50']"}, {}), "(['#0000aa', '#ff2020', '#50ff50'])", False, 'from matplotlib.colors import ListedColormap\n'), ((4, 6, 4, 44), 'matplotlib.colors.ListedColormap', 'ListedColormap', ({(4, 21, 4, 43): "['#0000aa', '#ff2020']"}, {}), "(['#0000aa', '#ff2020'])", False, 'from matplotlib.colors import ListedColormap\n')]