title: Python - Plotting and linear regression - x and y must be the same size
body: <p>I'm teaching myself some more tricks with python and scikit, and I'm trying to plot a linear regression model. My code can be seen below. But my program and console give the following error: <code>x and y must be the same size</code>. Additionally, my program makes it to the end of my code, but nothing gets plotted. </p>
  
  <p>To fix the size error, the first thing that came to mind was testing the length of x and y with something like <code>len(x) == len(y)</code>. But as far as I can tell, my data seems to be the same length. Maybe the error is referring to something other than length (if so, I'm not sure what). Would really appreciate any help.</p>
  
  <p><a href="https://i.stack.imgur.com/Xvyh5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xvyh5.png" alt="enter image description here"></a></p>
  
  <pre><code>from sklearn import cross_validation
  from sklearn.naive_bayes import GaussianNB
  from sklearn.model_selection import train_test_split
  from sklearn import linear_model
  import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  
  # Create linear regression object
  regr = linear_model.LinearRegression()
  
  #load csv file with pandas
  df = pd.read_csv("pokemon.csv")
  #remove all string columns
  df = df.drop(['Name','Type_1','Type_2','isLegendary','Color','Pr_Male','hasGender','Egg_Group_1','Egg_Group_2','hasMegaEvolution','Body_Style'], axis=1)
  
  y= df.Catch_Rate
  
  x_train, x_test, y_train, y_test = cross_validation.train_test_split(df, y, test_size=0.25, random_state=0)
  
  # Train the model using the training sets
  regr.fit(x_train, y_train)
  
  # Make predictions using the testing set
  pokemon_y_pred = regr.predict(x_test)
  
  print (pokemon_y_pred)
  
  # Plot outputs
  plt.title("Linear Regression Model of Catch Rate")
  plt.scatter(x_test, y_test,  color='black')
  plt.plot(x_test, pokemon_y_pred, color='blue', linewidth=3)
  
  plt.xticks(())
  plt.yticks(())
  
  plt.show()
  </code></pre>