How to place marker on one line and get coordinates
<p>1)I want to place a marker on one line,(between two points) in function of the lenght of the line.</p>

<p>2)I want to know the coordinates of this point/marker.</p>

<pre><code>import matplotlib.pyplot as plt
import math
x1 = 0
x2 = 9
y1 = 5
y2 = 7
plt.plot((x1, x2), (y1, y2))
lenghtline1 = math.sqrt((x1-x2)**2 + (y1-y2)**2)
</code></pre>

<p>Here the distance between the two points is 9.2 , </p>

<p>How can i put a marker in the line(between the two points) to 6 from point1?</p>

<p>How can i know the coordinates (x,y) of this marker?
thank you</p>

<pre><code>from pylab import *
from scipy import interpolate

x = rand(21).cumsum() # create some 21 random x values 
y = rand(len(x)) # the corresponding y values
plot(x, y, ".-")
xc = x[:-1]  + diff(x)/2. 
yc = interpolate.interp1d(x, y, kind="linear")(xc) # (xc, yc) are the marker positions

lengths = sqrt(diff(x)**2 + diff(y)**2) # lengths of the sections
scatter(xc,yc,c=cm.gray(lengths/lengths.max()), s=40) # visualization
show()
</code></pre>

python python-3.x numpy math matplotlib