I am plotting within a for loop. So that I get a new graph each iteration. Of course I want to clear the graph from the previous iteration. When I use plt.cla()
the axis labels and title is also cleared. How can I just remove the graph but keep the axis labels and title?
for n in range(N):
ax.plot(x[n],t) # plot
plt.savefig(f'fig_{n}.png') # save the plot
plt.cla()