title: How to extract an arbitrary line of values from a numpy array?
body: <p>I have a numpy array that contains some image data. I would like to plot the 'profile' of a transect drawn across the image. The simplest case is a profile running parallel to the edge of the image, so if the image array is <code>imdat</code>, then the profile at a selected point <code>(r,c)</code> is simply <code>imdat[r]</code> (horizontal) or <code>imdat[:,c]</code> (vertical).</p>
  
  <p>Now, I want to take as input two points <code>(r1,c1)</code> and <code>(r2,c2)</code>, both lying inside <code>imdat</code>. I would like to plot the profile of the values along the line connecting these two points.</p>
  
  <p>What is the best way to get values from a numpy array, along such a line? More generally, along a path/polygon?</p>
  
  <p>I have used slicing and indexing before, but I can't seem to arrive at an elegant solution for such a where consecutive slice elements are not in the same row or column. Thanks for your help.</p>