Training plot is not appearing properly for keras model

I have data where I need to train it with X and Y. Traning part is done but when I want to plot the prediction and actual data, it is appearing with so many lines instead of showing just non-linear regression line.

model= Sequential()
model.add(Dense(7,input_dim=1, activation="tanh"))
model.add(Dense(1))

model.compile(loss="mse", 
optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), metrics= 
["mae"])
history=model.fit(X,Y,epochs=1000)

predict=model.predict(X)
plt.scatter(X, Y,edgecolors='g')
plt.plot(X, predict,'r')
plt.legend([ 'Predictated Y' ,'Actual Y'])
plt.show()

Please see the attached imageplotting image

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum