Why am I getting misaligned values while plotting heatmaps using seaborn? While plotting heatmaps using seaborn, the numbers are getting printed on the boundary of the heatmap (Please see the image attached). I have already plotted heatmaps many times using the same code. It used to work well but since a few days, I'm facing this issue of misalignment.

Code:

#Defining a custom function
def get_confusion_matrix(clf,X_te,y_test):
y_pred = clf.predict(X_te)
df_cm = pd.DataFrame(confusion_matrix(y_test, y_pred), range(2),range(2))
df_cm.columns = ['Predicted NO','Predicted YES']
df_cm = df_cm.rename({0: 'Actual NO', 1: 'Actual YES'})
sns.set(font_scale=1.4)#for label size
sns.heatmap(df_cm, annot=True,annot_kws={"size": 16}, fmt='d',cmap="YlGnBu", linewidths=5)


#Using the function to plot the heatmap
get_confusion_matrix(model_s1,X_tr,y_train_1)


Kindly help.
There seems to be an issue with the matlpotlib package.
3.1.1 update has caused issues with heatmaps.
Downgrading to v3.1.0 fixes this issue.
Use the following code to downgrade.

pip install matplotlib==3.1.0


Refer this github discussion for details