2

I am trying to plot 6 different plots on matplot lib and save them each to a folder. However, it looks like they are all plotting on top of each other, so the first saved image is correct, but the second is just the second plot on top of the first plot. I would like the second plot, and all following, to just be that plot, not on top of the previous one. This is the code I have used, thank you so much!

for x in range(len(sizeDict)):
    plt.plot(xAxis,sizeDict[x])
    plt.title('size'+str(x))
    plt.savefig("/Users/name/Desktop/Work/Size"+ str(x) + ".png")

for x in range(len(shapeDict)):
    plt.plot(xAxis,shapeDict[x])
    plt.title('shape'+str(x))
    plt.savefig("/Users/Name/Desktop/Work/Shape"+ str(x) + ".png")
  • 2
    Does this answer your question? [Closing pyplot windows](https://stackoverflow.com/questions/11140787/closing-pyplot-windows) – Red Jun 26 '20 at 19:01

1 Answers1

2

You need to either create another figure or close the current one. You can use plt.figure() to create a new one or plt.close() to close the current one.

busybear
  • 10,194
  • 1
  • 25
  • 42