I wanted to plot y=(x+2)(x−1)(x−2)
for x going from −3 to 3 using a dashed red line. When I wrote the following code, nothing shows up.
import numpy as np
import matplotlib.pyplot as plt
def graph(formula, x_range):
x = np.array(x_range)
y = eval(formula)
plt.plot(x, y)
plt.show()
graph('((x-3) * (x-2))', range(-3,3))