咱們在學習人工智能的時候,會常常用到matplotlib,在學習的時候有一些例子寫了代碼運行:python
import matplotlib.pyplot as plt import numpy as np x = np.arange(20) y = [x_i + np.random.rand(1) for x_i in x] a, b = np.polyfit(x, y, 1) plt.plot(x, y, 'o', np.arange(20), a*np.arange(20)+b, '-');
點擊運行後卻無反應dom
Process finished with exit code 0學習
其實很簡單,只須要加上plt.show()
便可。人工智能
import matplotlib.pyplot as plt import numpy as np x = np.arange(20) y = [x_i + np.random.rand(1) for x_i in x] a, b = np.polyfit(x, y, 1) plt.plot(x, y, 'o', np.arange(20), a*np.arange(20)+b, '-'); plt.show()