Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีปิด Keyboard Shortcuts ใน Matplotlib


เพื่อปิด Keyboard Shortcuts ใน Matplotlib ใช้เมธอด remove('s')

ขั้นตอน

  • ตั้งค่าขนาดรูปและ padding ระหว่าง subplots
  • ปิด shortcut "s" (บันทึกรูป) ด้วย remove("s")
  • กำหนดตัวแปร n จำนวนจุดข้อมูล
  • สร้าง x และ y ด้วย numpy
  • พลอต x และ y ด้วย plot()
  • แสดงรูปด้วย 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()

ผลลัพธ์

วิธีปิด Keyboard Shortcuts ใน Matplotlib