title: x and Y must have the same first dimensions
body: <p>I am trying to graph the running average of the first 1,000 points of the data (number of sunspots per month). I am supposed to use Y_k=t/2r(sum from m=-r to r of Y_k+m) where r=5 and y_k is the number of sunspots. I have this so far. I have already imported all the built in functions</p>
  
  <pre><code>   if part == 'C':
      y = data[:,1]
      x = data[:,0]
  
  
      x_2 = x[:1000]
      y_Average_Sunspot = np.empty(1000,float) 
  
      y_Avg = y[:1000]
      x_Avg = x[:1000]
  
      y_n5 = (y_Avg)-5
      y_n4 = (y_Avg)-4
      y_n3 = (y_Avg)-3
      y_n2 = (y_Avg)-2
      y_n1 = (y_Avg)-1
      y_1 = (y_Avg)+1
      y_2 = (y_Avg)+2
      y_3 = (y_Avg)+3
      y_4 = (y_Avg)+4
      y_5 = (y_Avg)+5
  
      y_Average = (y_5)+(y_4)+(y_3)+(y_2)+(y_1)+(y_n1)+(y_n2)+(y_n3)+(y_n4)+(y_n5)+(y_Avg)
  
      y_Average_Sunspots = y_Average/10
  
  
  
      plt.plot(x_2,y,label='First Thousand Months',color='y')
      plt.plot(x_Avg, y_Average_Sunspot,label='Running Average', color='k')
      plt.xlim(0,1000)
      plt.ylim(0,1000)
      plt.xlabel('Time (months)')
      plt.ylabel('Number of Sunspots')
      plt.legend(loc=9)
      plt.show()
  </code></pre>
  
  <p>The problem is when I import it says that x and y need to have the same first dimension. I have checked the shape and size of every array  in this program and they are all the same. </p>
  
  <p>the Full Error Trace back</p>
  
  <p>ValueError                                Traceback (most recent call last)
   in ()</p>
  
  <p>----> 1 ps.plot_sunspots('C')</p>
  
  <p>/home/loberhel/ASTR260/HW2/plot_sunspot.pyc in plot_sunspots(part)
      111 
      112 
  --> 113         plt.plot(x_2,y,label='First Thousand Months',color='y')</p>
  
  <pre><code>114         plt.plot(x_Avg, y_Average_Sunspot,label='Running Average', 
  </code></pre>
  
  <p>color='k')
      115         plt.xlim(0,1000)</p>
  
  <p>/usr/lib64/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, </p>
  
  <p>**kwargs)
     2985         ax.hold(hold)</p>
  
  <p>2986     try:</p>
  
  <p>-> 2987         ret = ax.plot(*args, **kwargs)</p>
  
  <p>2988         draw_if_interactive()</p>
  
  <p>2989     finally:</p>
  
  <p>/usr/lib64/python2.7/site-packages/matplotlib/axes.pyc in plot(self, *args, </p>
  
  <p>**kwargs)</p>
  
  <p>4135         lines = []
     4136 
  -> 4137         for line in self._get_lines(*args, **kwargs):</p>
  
  <p>4138             self.add_line(line)</p>
  
  <p>4139             lines.append(line)</p>
  
  <p>/usr/lib64/python2.7/site-packages/matplotlib/axes.pyc in </p>
  
  <p>_grab_next_args(self, *args, **kwargs)</p>
  
  <pre><code>315                 return
  
  316             if len(remaining) &lt;= 3:
  </code></pre>
  
  <p>--> 317                 for seg in self._plot_args(remaining, kwargs):</p>
  
  <pre><code>318                     yield seg
  
  319                 return
  </code></pre>
  
  <p>/usr/lib64/python2.7/site-packages/matplotlib/axes.pyc in _plot_args(self, tup, kwargs)
      293             x = np.arange(y.shape[0], dtype=float)
      294 
  --> 295         x, y = self._xy_from_xy(x, y)
      296 
      297         if self.command == 'plot':</p>
  
  <p>/usr/lib64/python2.7/site-packages/matplotlib/axes.pyc in _xy_from_xy(self, x, y)
      235         y = np.atleast_1d(y)</p>
  
  <pre><code>236         if x.shape[0] != y.shape[0]:
  </code></pre>
  
  <p>--> 237             raise ValueError("x and y must have same first dimension")</p>
  
  <pre><code>238         if x.ndim &gt; 2 or y.ndim &gt; 2:
  
  239             raise ValueError("x and y can be no greater than 2-D")
  </code></pre>
  
  <p>ValueError: x and y must have same first dimension</p>