from matplotlib.colors import ListedColormap cmap = np.zeros([256, 4]) cmap[:, 3] = np.linspace(0, 1, 256) cmap = ListedColormap(cmap)