介紹
在vscode運行下面這段代碼:
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 20, 100) # Create a list of evenly-spaced numbers over the range
plt.plot(x, np.sin(x)) # Plot the sine of each x point
plt.show() # Display the plot
可以畫個正弦函數圖:
一開始沒裝matplotlib的話是使用不了的。
方法
在terminal輸入安裝,回車即可。
pip install matplotlib
然後可以用文章開頭的代碼測試一下。