from sympy import *
# create symbol X
x = symbols('x')
# define f(x)
f = x**2 + 2*x + 1
f
plot(f)
# Differentiate f(x)
f_diff = diff(f)
f_diff
# Plot both
p1 = plot(f_diff,show=False,line_color="red")
p2 = plot(f,show=False)
p1.append(p2[0])
p1.show()