I want to graph the distance from a point to a line with mathplotlib, I manage to graph the line, the point, get the distance, but I cannot make the distance from that point to the line graph, I tried creating a line with axhline, but it is fixed, so if I change the value, the line is useless, I leave the code if it helps.
def ecuacion_recta(m, b,r,d5,d6):
x = range(-10, 10)
y = range(r)
plt.plot(x, [m*i+b for i in x])
plt.plot(2, 7, marker="o")
plt.axhline(0, color="black")
plt.axvline(0, color="black")
plt.xlim(-11, 11)
plt.ylim(-11, 11)
#intento de graficar la distancia
plt.plot(y, [b for j in y], )
plt.show()
this is printed if I do it with these data m= 0.5 b = -1 r = 6.28... d5 = 2 d6 = 7
I appreciate your guidance and time.
Here's an example of how to do it (see base , axes at equal scales ):
Result: