How can I remove a line (or lines) of a matplotlib axes in such a way as it actually gets garbage collected and releases the memory back? The below code appears to delete t
Hopefully this can help others: The above examples use ax.lines.
With more recent mpl (3.3.1), there is ax.get_lines().
This bypasses the need for calling ax.lines=[]
for line in ax.get_lines(): # ax.lines:
line.remove()
# ax.lines=[] # needed to complete removal when using ax.lines