I am trying to use a forloop to produce figures for each set of data I have, but while the .show() command produces the correct figure, .savefig() keeps adding the previous
I made some beautiful charts before I included plt.clf() to clear the plot each time through the loop. scatterplot1 scatterplot2
In other words, my previous plots were being added to a single figure as shown in the lots above, within my for loop as well. adding [plt.clf()
] to clear the plot each time through the loop fixed this problem being clearing the figure before starting the loop iteration at the top to create a new figure with new plots.
TLDR; I included plt.clf() to clear the plot each time through the loop.