如何在 Python 中顯示軸子圖?


要在 Python 中顯示一個軸子圖,我們可以使用 show() 方法。當建立了多個圖表時,這些影像使用 show() 方法進行顯示。

步驟

  • 使用 numpy 建立 x 和 y 資料點。
  • 使用 plot() 方法繪製 x 和 y。
  • 要顯示圖表,使用 show() 方法。

示例

from matplotlib import pyplot as plt
import numpy as np
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.arange(10)
y = np.exp(x)
plt.plot(x, y)
plt.show()

輸出

更新於: 2021-05-07

2K+ 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.