How to add points to the existing diagram? The straightforward solution is to plot a new scatter, adding new data.
ax.scatter(data[:,0], data[:,1], cmap = cmap, c = color_data)
ax.scatter(new_points_x, new_points_y, color='blue')
But if we want to add more points with new colors, there is a problem: we have to take into consideration all previously added points.
It would be great if I could use a special function like
AddPoint(ax, new_point, color)
I want only add new points in new colors. I do NOT need any animations
To just add a new data with new colour, indeed calling again scatter will add the new points with the specified colour:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(10)
a = np.random.rand(10)
plt.scatter(x, a, c='blue')
b = np.random.rand(10)
plt.scatter(x, b, c='red')
plt.show()

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With