title: Plot line graph for tested and predicted values in Python
body: <p>I have produced an OLS regression model where I have trained and tested the data:</p>
  <pre><code>from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size = 0.20)
  </code></pre>
  <p>I have then created the variable y_preds as follows:</p>
  <pre><code>X_test = sm.add_constant(X_test)
  y_preds = results.predict(X_test)
  </code></pre>
  <p>I am now trying to plot test and predicted data on a line graph to see how well the model fits however my method is not working:</p>
  <pre><code>df = pd.DataFrame({'Actual': y_test, 'Predicted': y_preds})
  
  df.plot(kind='line',figsize=(18,8))
  plt.grid(which='major', linestyle='-', linewidth='0.5', color='green')
  plt.grid(which='minor', linestyle=':', linewidth='0.5', color='black')
  plt.show()
  </code></pre>
  <p>What happens is that the line graph shows two lines all over the place instead of two overlapping lines that go from left to right.</p>
  <p>This is the link to the current output
  <a href="https://i.stack.imgur.com/YikUM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YikUM.png" alt="This is the link to the current output" /></a></p>
  <p>This is the link to the ideal output
  <a href="https://i.stack.imgur.com/OPc8n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OPc8n.png" alt="This is the link to the ideal output" /></a></p>