คุณmatplotlib.pyplot
จะ "ลืม" แผนการก่อนหน้านี้ได้อย่างไร
ฉันกำลังพยายามวางแผนหลายครั้งโดยใช้ไฟล์ matplotlib.pyplot
รหัสมีลักษณะดังนี้:
def plottest():
import numpy as np
import matplotlib.pyplot as plt
a=np.random.rand(10,)
b=np.random.rand(10,)
c=np.random.rand(10,)
plt.plot(a,label='a')
plt.plot(b,label='b')
plt.plot(c,label='c')
plt.legend(loc='upper left')
plt.ylabel('mag')
plt.xlabel('element)')
plt.show()
e=np.random.rand(10,)
f=np.random.rand(10,)
g=np.random.rand(10,)
plt.plot(e,label='e')
plt.plot(f,label='f')
plt.plot(g,label='g')
plt.legend(loc='upper left')
plt.ylabel('mag')
plt.xlabel('element)')
plt.show()
น่าเสียดายที่ฉันได้รับพล็อตเดิม ๆ ต่อไป (อันที่จริงแล้วมาจากโค้ดอื่น ๆ ที่ฉันรันและทำเสร็จเมื่อไม่นานมานี้) ไม่ว่าฉันจะทำอะไรก็ตาม
รหัสที่คล้ายกันใช้งานได้สำหรับฉันก่อนหน้านี้
ฉันได้ดูคำถามเหล่านี้แล้ว:
"ทำความสะอาดกระดานชนวน" อย่างไร?
Matplotlib pyplot show () ไม่ทำงานเมื่อปิดแล้ว
(python) matplotlib pyplot show () .. บล็อคหรือเปล่า?
และพยายามใช้plt.show()
, plt.clf()
และplt.close
จะไม่มีประโยชน์
ความคิดใด ๆ ?