How to fit linear slope to a graph in a specified range of x values?
<p>For example, here is a data set:</p>

<pre><code>X: 1,  2,  3,  4,  5,  6,  7,  8,  9,  10 

Y: 20, 21, 22, 26, 32, 41, 39, 36, 29, 23
</code></pre>

<p>I think I'm supposed to be using the NumPy <code>polyfit</code> function, but not sure.
How can I, for example, get the linear fit between <code>x(3)</code> and <code>x(6)</code>?</p>

<p>Just calculating in my head, this should be something like: <code>rise/run = (41-22)/(6-3) = 6.3333333...</code></p>

<p>I'm dealing with different data sets each time that I read in as <code>.txt</code> files, so I would really appreciate if someone showed me the general method to do this, which I could then apply to all future datasets.</p>