Unpack plot made with seaborn

Viewed 21

I'm trying to save this plot, but when I run the following code I get TypeError: cannot unpack non-iterable AxesSubplot object. How can I solve it?

filename = 'Results/confusion_matrix_'+model_name+'.png'
cm = confusion_matrix(labels_test_true, labels_test_pred[0,:])
fig, ax= plt.subplot()
sns.heatmap(cm, annot=True, fmt='g', ax=ax);
# labels, title and ticks
ax.set_xlabel('Predicted labels');ax.set_ylabel('True labels'); 
ax.set_title('Confusion Matrix'); 
ax.xaxis.set_ticklabels(['normal', 'anomaly']); ax.yaxis.set_ticklabels(['anomaly', 'normal']);
fig.savefig(filename)
0 Answers
Related