How to build two graphs in one figure from the equations below
- y = (x+2)^2
- y = sin(x/2)^2
There is my code:
import matplotlib.pyplot as plt import numpy as np from math import sin y = lambda x: sin(x / 2) ** 2 y1 = lambda x: (x + 2) ** 2 fig = plt.subplots() x = np.linspace(-3, 3, 100) plt.plot(x, y(x)) plt.plot(x, y1(x)) plt.show() 
mathfunctions with numpy arrays. Usenp.sin()instead. See here for more information on this problem.