Featured image of post 使用 Python (matplotlib.pyplot) 绘制图表的方法

使用 Python (matplotlib.pyplot) 绘制图表的方法

img_1.png

所需条件

  • Google 账号

步骤

  1. 访问 https://colab.research.google.com/
  2. 选择“文件” -> “新建笔记本”
  3. 粘贴并运行以下代码
1
2
3
4
5
6
7
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 500)
plt.plot(x, np.sin(x), label="sin curve")
plt.plot(x, np.cos(x), label="cos curve")
plt.legend() # 显示图例
plt.show()

运行结果

img.png

参考资料

comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计