Seaborn Heatmap轴格式反转图形

时间:2019-03-20 02:43:36

标签: seaborn heatmap

当我添加x轴的格式时,图形保持不变。当我设置y轴刻度标签的格式时,图形会反转并且我无法弄清楚原因。

y轴格式之前的热图

heatmap before y-axis format

这是x轴格式之后的图形

heatmap after y-axis format

ax = sns.heatmap(All_new, linewidths=.5, annot=True, cmap="RdYlGn")
plt.tight_layout()
plt.xlabel('Losing Digit')
plt.ylabel('Winning Digit')
plt.title('Total Distribution of Final Digits (%)')
ax.get_xaxis().set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x))))
ax.get_yaxis().set_major_formatter(matplotlib.ticker.FuncFormatter(lambda x, p: format(int(x))))
#ax.invert_yaxis()
plt.show()

0 个答案:

没有答案