Logo
0

调整Seaborn热力图坐标刻度

调整Seaborn热力图坐标刻度

seaborn基于matplotlib实现,seaborn所作的热力图的坐标轴刻度通过对ax的操作来设定完成 ❗但是必须要在sns.heatmap()执行之后进行ax.set_xticks()和ax.set_yticks()才能生效

  import seaborn as sns
  import matplotlib.pyplot as plt
  import numpy as np

  data = np.random.random((10, 10))
  # 如果想对seaborn所画的图进行细致的操作,推荐从matplotlib的fig和ax做起
  fig = plt.figure()
  ax = fig.add_subplot(111)

  sns.heatmap(data)
  ax.set_yticks([0,1,2,3,4,5,6, 7, 8, 9, 10], [0,1,2,3,4,5,6, 7, 8, 9, 10][::-1])

© 2025 All rights reservedBuilt with DataHub Cloud

Built with LogoDataHub Cloud