Plot an expression

lambdify, plt.plot, plt.show.

lambdify then plt.plot then plt.show().

Goal

Plot the factored quadratic's value on [-1, 6].

import numpy as np
import sympy as sp
x = sp.symbols('x')
f = sp.lambdify(x, x ** 2 - 5 * x + 6, 'numpy')
xs = np.linspace(-1, 6, 80)
plt.plot(xs, f(xs))
plt.axhline(0, color='gray')
plt.title('x^2 - 5x + 6')
plt.show()
print('roots near 2 and 3')
import numpy as np
import sympy as sp
x = sp.symbols('x')
f = sp.lambdify(x, sp.sin(x), 'numpy')
xs = np.linspace(0, 2 * np.pi, 80)
plt.plot(xs, f(xs))
plt.show()
print('ok')