matplotlib在vscode上使用

介紹

在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

在這裏插入圖片描述
然後可以用文章開頭的代碼測試一下。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章