'matplotlib python finding graph intersection with x-axis

I have following code:

from matplotlib import pyplot as plt
import numpy as np

x = np.linspace(-10, 10, 500)
Y = input("y = ")
y = eval(Y)

plt.axhline(0, color = "black") #x-axis
plt.axvline(0, color = "black") #y-axis
plt.grid() 
plt.plot(x, y)

x = 0
y0 = eval(Y) 
plt.plot(x, y0, marker="o", markersize=5, markerfacecolor="red", markeredgecolor="black")          
plt.annotate("[" + str(x) + ", " + str(y0) + "]", (x, y0))
plt.show()

I have found and annotated the intersection with y-axis. Now I would like to do the same with x-axis, but I can't find a way to do so. Can anybody help me?

Screenshot



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source