0
我想通過seaborn繪製一個混淆矩陣,但當它們旋轉到90度時無法將yticklabels居中對齊。雖然 ha工作沒有旋轉,但旋轉失敗。這裏是最小的工作示例 -如何居中對齊seaborn中旋轉的yticklabels?
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
cmat = np.matrix([[2, 3], [4, 5]])
fig, ax = plt.subplots(figsize=(4, 4))
sns.heatmap(cm_greina, annot=True, xticklabels=['Faulty', 'Healthy'], cbar=False, ax=ax)
ax.set_yticklabels(['Faulty', 'Healthy'], rotation=90, ha='center')
任何幫助將不勝感激。
嘗試加入'rotation_mode ='anchor'' –
完美!這工作!感謝您的及時迴應。 –
你們中的一個人會發佈一個答案,所以這個問題被關閉了嗎? –