from matplotlib.colors import ListedColormap
sm = plt.cm.ScalarMappable(cmap=ListedColormap(color_palette), norm=plt.
    Normalize(vmin=0, vmax=3))
sm._A = []
plt.colorbar(sm)
How to add `colorbar` to `networkx` using a `seaborn` color palette? (Python 3)