title: Question about applying PCA with one Component
body: <p>I have a set of data that I've been assigned to apply PCA and retain one component and then visualize the distribution in a scatter plot which indicates the class of each data point.</p>
  
  <p>For context: The data we're working with has three columns. X is column 1 and 2 and y is column 3 which contains the class of each data point. </p>
  
  <p>It was implied that the resulting visualization should be a horizontal line, but I'm not seeing that. The resulting visualization is a scatter plot that looks like a positive linear distribution. </p>
  
  <pre><code>import pandas as pd
  import sklearn
  from sklearn.model_selection import train_test_split
  import numpy as np
  from sklearn.preprocessing import StandardScaler
  from sklearn.decomposition import PCA
  import matplotlib.pyplot as plt
  from matplotlib.colors import ListedColormap
  
  
  df = pd.read_csv("data.csv", header=None)
  X = df.iloc[:, 0:2].values
  y = df.iloc[:,-1].values
  X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.3,random_state=np.random)
  sc_X = StandardScaler()
  X_train = sc_X.fit_transform(X_train)
  X_test = sc_X.transform(X_test)
  
  pcaObj1 = PCA(n_components=1)
  X_train_PCA = pcaObj1.fit_transform(X_train)
  X_test_PCA = pcaObj1.transform(X_test)
  X_set, y_set = X_test_PCA, y_test
  X3 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01))
  X3 = np.array(X3)
  
  plt.xlim(X3.min(), X3.max())
  plt.ylim(X3.min(), X3.max())
  for i, j in enumerate(np.unique(y_set)):
      plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 0],
                  c = ListedColormap(('purple', 'yellow'))(i), label = j)
  </code></pre>