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

在这里插入图片描述
然后可以用文章开头的代码测试一下。

发布了103 篇原创文章 · 获赞 102 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/Davidietop/article/details/105594021