简体   繁体   中英

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?

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM