I have a scatterplot and I want to color it based on another value (naively assigned to np.random.random()
in this case).
Is there a way to use
from matplotlib.cm import ScalarMappable
from matplotlib.colors import Normalize
cmap = {obsv_id:np.random.random() for obsv_id in DF_PCA.index}
sm = ScalarMappable(norm=Normalize(vmin=min(list(cmap.values())), vmax=max(list(cmap.values()))), cmap=sns.cubehelix_palette(as_cmap=True))
# Plot
fig, ax = plt.subplots()
ax.scatter(x=DF_PCA["PC1"], y=DF_PCA["PC2"], color=[sm.to_rgba(cmap[obsv_id]) for obsv_id in DF_PCA.index])
ax.set_title("With Coloring")