Benjo
Benjo

Reputation: 147

Matplotlib highlighting a point on plot with a horizontal and vertical line

Im just trying to work out how to draw the lines as outlined in the picture below. I'm reading through W3Scools polynomial regression and I can't work out how to replicate the highlighted point on the curve with the horizontal and vertical orange lines. https://www.w3schools.com/python/python_ml_polynomial_regression.asp

Is it just a simple case of drawing the lines in or is there a matplotlib function that does this for you?

Upvotes: 1

Views: 637

Answers (1)

Jan Willem
Jan Willem

Reputation: 1094

How about just plotting it as a line.

x_coord = # x value you want to highlight
y_coord = # y value you want to highlight

x_highlighting = [0, x_coord, x_coord]
y_highlighting = [y_coord, y_coord, 0]

plt.plot(x_highlighting, y_highlighting)

Upvotes: 2

Related Questions