title: ValueError: x and y can be no greater than 2-D, but have shapes (2, 1, 1) and (2,)
body: <p><strong>Source code</strong></p>
  <pre><code>cyprus_predicted_life_satisfaction = lin1.predict(cyprus_gdp_per_capita)[0][0]
  #cyprus_predicted_life_satisfaction = lin1.predict(cyprus_gdp_per_capita)
  
  cyprus_predicted_life_satisfaction
  </code></pre>
  <p>OUT: <code>array([[5.96244744]])</code></p>
  <pre><code>sample_data.plot(kind='scatter', x=&quot;GDP per capita&quot;, y='Life satisfaction', figsize=(5,3), s=1)
  X=np.linspace(0, 60000, 1000)
  plt.plot(X, t0 + t1*X, &quot;b&quot;)
  plt.axis([0, 60000, 0, 10])
  plt.text(5000, 7.5, r&quot;$\theta_0 = 4.85$&quot;, fontsize=14, color=&quot;b&quot;)
  plt.text(5000, 6.6, r&quot;$\theta_1 = 4.91 \times 10^{-5}$&quot;, fontsize=14, color=&quot;b&quot;)
  plt.plot([cyprus_gdp_per_capita, cyprus_gdp_per_capita], [0, cyprus_predicted_life_satisfaction], &quot;r--&quot;)
  plt.text(25000, 5.0, r&quot;Prediction = 5.96&quot;, fontsize=14, color=&quot;b&quot;)
  plt.plot(cyprus_gdp_per_capita, cyprus_predicted_life_satisfaction, &quot;ro&quot;)
  save_fig('cyprus_prediction_plot')
  plt.show()
  </code></pre>
  <p><strong>ERROR</strong></p>
  <pre><code>---------------------------------------------------------------------------
  ValueError                                Traceback (most recent call last)
  &lt;ipython-input-36-c7d7af89ced4&gt; in &lt;module&gt;
        5 plt.text(5000, 7.5, r&quot;$\theta_0 = 4.85$&quot;, fontsize=14, color=&quot;b&quot;)
        6 plt.text(5000, 6.6, r&quot;$\theta_1 = 4.91 \times 10^{-5}$&quot;, fontsize=14, color=&quot;b&quot;)
  ----&gt; 7 plt.plot([cyprus_gdp_per_capita, cyprus_gdp_per_capita], [0, cyprus_predicted_life_satisfaction], &quot;r--&quot;)
        8 plt.text(25000, 5.0, r&quot;Prediction = 5.96&quot;, fontsize=14, color=&quot;b&quot;)
        9 plt.plot(cyprus_gdp_per_capita, cyprus_predicted_life_satisfaction, &quot;ro&quot;)
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
     2809     return gca().plot(
     2810         *args, scalex=scalex, scaley=scaley, **({&quot;data&quot;: data} if data
  -&gt; 2811         is not None else {}), **kwargs)
     2812 
     2813 
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/__init__.py in inner(ax, data, *args, **kwargs)
     1808                         &quot;the Matplotlib list!)&quot; % (label_namer, func.__name__),
     1809                         RuntimeWarning, stacklevel=2)
  -&gt; 1810             return func(ax, *args, **kwargs)
     1811 
     1812         inner.__doc__ = _add_data_doc(inner.__doc__,
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, *args, **kwargs)
     1609         kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
     1610 
  -&gt; 1611         for line in self._get_lines(*args, **kwargs):
     1612             self.add_line(line)
     1613             lines.append(line)
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
      391                 this += args[0],
      392                 args = args[1:]
  --&gt; 393             yield from self._plot_args(this, kwargs)
      394 
      395 
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
      368             x, y = index_of(tup[-1])
      369 
  --&gt; 370         x, y = self._xy_from_xy(x, y)
      371 
      372         if self.command == 'plot':
  
  ~/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
      232         if x.ndim &gt; 2 or y.ndim &gt; 2:
      233             raise ValueError(&quot;x and y can be no greater than 2-D, but have &quot;
  --&gt; 234                              &quot;shapes {} and {}&quot;.format(x.shape, y.shape))
      235 
      236         if x.ndim == 1:
  
  ValueError: x and y can be no greater than 2-D, but have shapes (2, 1, 1) and (2,)
  </code></pre>
  <p><strong>Tried Solutions</strong></p>
  <ul>
  <li>This question has their dimensional problem in the opposite 1D and 3D in my case it is 3D and 1D - <a href="https://stackoverflow.com/questions/53944197/problem-plotting-an-images-fourier-transforms-valueerror-x-and-y-can-be-no-g/">Problem plotting an image&#39;s Fourier transforms. &quot;ValueError: x and y can be no greater than 2-D, but have shapes (2592,) and (2592, 1, 3)&quot;</a></li>
  <li>NO ANSWER: <a href="https://stackoverflow.com/questions/55105122/error-x-and-y-can-be-no-greater-than-2-d-but-have-shapes-2-and-2-150000">Error: x and y can be no greater than 2-D, but have shapes (2,) and (2, 150000, 1)</a></li>
  <li>NO ANSWER - <a href="https://stackoverflow.com/questions/59879337/x-and-y-can-be-no-greater-than-2-d-but-have-shapes-1-and-1-224-224-3">x and y can be no greater than 2-D, but have shapes (1,) and (1, 224, 224, 3)</a></li>
  </ul>