title: plot specific columns and rows from a file with pylab
body: <p>I have a data file where I want to plot specific lines of the second column. My script is as follows:</p>
  
  <pre><code>f=open('datafile','r')
  lines1=f.readlines()[4:24]#since I want the values from the 4th to the 23rd line
  lines2=f.readlines()[33:54]#I want the values from the 33rd to the 53rd line
  f.close()
  
  x1=[]
  y1=[]
  
  for line in lines1:
      p=line.split()
      x1.append(float(p[1]))#the values are in the second column
  for line in line2:
      p=line.split()
      y1.append(float(p[1]))
  
  xv=np.array(x1)
  yv=np.array(y1)
  
  plt.plot(xv,yv)
  </code></pre>
  
  <p>However, at the end I have an error saying "x and y must have same first dimension". I am not very experienced with python, could somebody advise me any alternative or let me know what am I doing wrong? How could I extract only those rows with a different way?</p>
  
  <p>I want to plot x= column 2 from row 4 to row 25 against y=column 2 from row 33 to row 54.</p>
  
  <p>Thank you very much in advance.</p>
  
  <p>Regards,</p>
  
  <p>Gio</p>