ใช้ plot() คืนค่า list ของ Line2D objects ใช้ pop() แล้ว remove()
ตัวอย่างโค้ด
from matplotlib import pyplot as plt, image as mimg
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
line_1 = plt.plot([1, 2, 3])
line_2 = plt.plot([2, 4, 6])
line = line_2.pop(0)
line.remove()
plt.show()
ผลลัพธ์
เหลือแค่เส้นแรก (1,2,3) เส้นที่สองถูกลบ
