To plot y=1/x as a single graph in Python, we can take the following steps −
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 101) plt.plot(x, 1/x, label='$f(x)=\frac{1}{x}$') plt.legend(loc='upper left') plt.show()