Resetting matplotlib before writing heatmaps