我正在使用来自matplotlib的子图来绘制路缘石。我希望我的脚本绘制一个路边,然后擦除它,然后再绘制另一个路边,但又不删除“环境”(例如,副标题或xlabel
)。
我通常使用plt.cla()
,但是它会删除“环境”,因此每次我绘制路边石时都会迫使我再次设置环境。
import matplotlib.pyplot as plt
fig=plt.figure()
ax1=fig.add_subplot(121)
ax2=fig.add_subplot(122)
ax1.set_xlabel('x')
ax1.set_title('Title')
firstCurb=[1,2,3]
secondCurb=[4,5,6]
ax1.plot(firstCurb)
ax1.cla()
ax1.plot(secondCurb)
我绘制了第二条路缘,但没有轴的标题或子图的标题。
是否有命令来清除路边石而不是环境?预先感谢。