In matplotlib (from the code I assume you're using it) documentation there is an information for matplotlib.pyplot.scatter
function, first two parameters are:
x, y : float or array-like, shape (n, )
The data positions.
So for your application you need to draw two scatterplots on the same graph - using matplotlib.pyplot.scatter
twice. First with y_test
as y
and color='red'
, second with y_pred
as y
and color='blue'
Unfortunately, you didn't provide information what you x values for y_test and y_pred, but you will need those as well to define x
in your plt.scatter
function calls.
Drawing two scatter plots is slightly tricky, and as this answer says it requires a reference to an Axes
object. For example (as given in the answer):
import matplotlib.pyplot as plt
x = range(100)
y = range(100,200)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.scatter(x[:4], y[:4], s=10, c='b', marker="s", label='first')
ax1.scatter(x[40:],y[40:], s=10, c='r', marker="o", label='second')
Take a look at the matplotlib documentation and the mentioned answer for more details.