I am plotting a Linear Regression model using pyplot. Below is my code.
plt.scatter(X_train, y_train, color ='red')
plt.show()
When I plot using the above code, the plot is as shown below:

I then plotted the line graph using the code below:
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.show()
But when I try to plot both of them together, the graph is getting messed up as shown below:
plt.scatter(X_train, y_train, color ='red')
plt.plot(X_train, regressor.predict(X_train), color = 'blue')
plt.show()
Please let me know if I have to do any extra coding to plot a Linear regression graph properly.

