import numpy as np import matplotlib.pyplot as plt def f(x): return x**2 + 1 dx = 0.1 x_array = np.arange(-2, 2+dx, dx) n = len(x_array) y_array = np.zeros(n) for i in range(0, n, 1): y_array[i] = f(x_array[i]) plt.close('all') plt.plot(x_array, y_array, label='y') plt.legend() plt.xlabel('x') plt.grid() # plt.savefig('plot_fun_2ord.pdf') plt.show()