如何在 Python 中的 Matplotlib 線條上繪製外邊緣輪廓?


要在 Python 中的 Matplotlib 中繪製外邊緣輪廓,我們可以採取以下步驟:

  • 設定影像尺寸並調整子圖之間和周圍的填充。
  • 使用 numpy 建立 x 和 y 資料點。
  • 繪製 x 和 y 資料點,並將線寬設定為 10 和 5,以獲得可見的輪廓邊緣。
  • 使用 show() 方法顯示圖形。

示例

import numpy as np
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = np.linspace(-10, 10, 100)
y = np.sin(x)

plt.plot(x, y, lw=10, color='red')
plt.plot(x, y, lw=5, color='yellow')

plt.show()

輸出

更新於:2021-08-04

1K+ 瀏覽

開始您的職業生涯

完成該課程獲得認證

立即開始
廣告