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 設計