如何停用 Matplotlib 中的鍵盤快捷鍵?
要停用 Matplotlib 中的鍵盤快捷鍵,我們可以使用remove('s') 方法。
步驟
- 設定圖形尺寸並調整子圖之間和周圍的邊距。
- 要停用"s" 儲存圖形的快捷鍵,請使用remove("s") 方法。
- 初始化變數n,用於表示資料點數量。
- 使用 numpy 建立x 和y 資料點
- 使用plot() 方法繪製x 和y 資料點。
- 要顯示圖形,請使用show() 方法。
例
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True plt.rcParams['keymap.save'].remove('s') n = 10 x = np.random.rand(n) y = np.random.rand(n) plt.plot(x, y) plt.show()
輸出
廣告