Please see code below. I am trying to get 2 exact same scatter plots, in ax2 I try to set the color after the scatter plot has been created. How can I achieve this?
I want this because in my interface I am trying to have the user (optionally) select data to color the scatterplot with. I could just redo the whole plot but I am guessing for large number of data points, it is better add colors to existing axis object. Is that correct?
import numpy as np
import matplotlib.pyplot as plt
fig, (ax1,ax2) = plt.subplots(1,2)
x = np.random.rand(100)
y = np.random.rand(100)
z = np.random.rand(100)
#in ax1, I set color using the 'c' argument
ax1.scatter(x,y, c=z)
sc = ax2.scatter(x,y)
#in ax2, I try to mimic the 'c' argument with set_color but it raises error
# sc.set_color(z)