'how to export heat maps as png images

I am working on plotting heat maps using seaborn and I want to export them to the hard disk as png images for some how my code is blocking at the savefig line :

def plot_scaterring_matrix(data_plot, UWB_id, activity_name, filt_step):
   data_plot=np.absolute(data_plot)
   NY=data_plot.shape[1]
   NX=data_plot.shape[0]
   sns.heatmap(data_plot, xticklabels=500, yticklabels=25, annot=True)
   plt.title('scaterring matrix .....')  
   plt.xlabel("B...")
   plt.ylabel("F...")
   print()
   print('type of time step', type(timestep))
   plt.savefig(path+'.png', format="png")
   plt.close()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source