When using matplotlibs scatter function, it is pretty neat to display data with colors:
data = np.random.random((3, 10))
scatter = plt.scatter(data[0], data[1], c=data[2], cmap='Viridis')
This will automatically map data[2]
to a color spectrum that conveys information. Is there a nice way to do that outside of the scatter function?
One reason why Im asking this is because I try to change the colors later. There is a question about it here, but I realised that this will use the normalisation of the old array.
Say I want to change the array that is mapped as colors:
new_colors = 10 * np.random.random(10)
scatter.set_array(new_colors)
This will make almost all points the brightest color instead of choosing an appropriate new range of colors.
Is there a way to circumvent this? Or alternatively can I nicely make a colorarray from this and then pass it to scatter.set_color()