i just started learning python matplotlib. i want draw y = 1/x linespace in python matplotlib.pyplot. but as you see the picture, asymptote show up in graph. i want to remove the asymptote. how to make this? thank you for reading my question.
https://i.stack.imgur.com/P9LPO.png
here is my code
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-5,5,1000)
y = 1 /x
fig, ax = plt.subplots()
ax.plot(x,y,linewidth=2.0)
ax.set(xticks=np.arange(-6,6), ylim=(-20,20))
plt.show()
just try exclude x =0. but it feels difficult and i think there is another way.
please explain me or show code.