1

I am trying to create a heatmap with matplotlib and save it to my assets. When I call my program again no new heatmap is created but the old heatmap is overlaid. How can I prevent this?

    sns.heatmap(corr1, annot=True,vmin=0, vmax=1, xticklabels="auto", yticklabels="auto", cbar=True)
    plt.title('Pears Rangkorrelation')
    plt.tight_layout()
    dir_name= 'C:/Users/Steffen/Documents/Studium/Bachelorarbeit/Programm/client/src/assets/'
    plt.rcParams["savefig.directory"]= os.chdir(os.path.dirname(dir_name))
    plt.savefig('Pears_Rangkorrelation.png')````
Redox
  • 9,321
  • 5
  • 9
  • 26
Steffen
  • 13
  • 2
  • Does this answer your question? [Clearing a subplot in Matplotlib](https://stackoverflow.com/questions/47282918/clearing-a-subplot-in-matplotlib) – Jody Klymak Jul 04 '22 at 16:11

0 Answers0