1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Matplotlibとseabornで複数のヒートマップを描写したい

Last updated at Posted at 2022-11-15

経緯

簡単だと思ったら思いのほか詰まる描画。。。
探しても微妙に出てこないし備忘録として作ろうと思う。

コード

labels = ['A','B','C','D','E','F','G','H']

for i in range(0,4):
  data_list += [[[i]* 8]* 8]
def heatmap(list, ax, labels):
  # print(labels)
  sns.heatmap(list, ax= ax, vmin=0.5, vmax=3, cmap="YlOrRd", annot=True)
  ticks_pos = range(2, 8, 4)
  ax.set_xticks(ticks=ticks_pos)
  ax.set_xticklabels(labels=labels)
  ax.set_yticks(ticks=ticks_pos)
  ax.set_yticklabels(labels=labels)
  ax.plot([0,8], [4,4], ls='--', lw=1, color='b')
  ax.plot([4,4], [0,8], ls='--', lw=1, color='b')
  # labels=labels
#日本語にする
sns.set(font_scale=1.1, font="IPAexGothic") 

def cos_heatmaps(lists):
  fig = plt.figure(figsize=(12, 10))
  ax1 = fig.add_subplot(221)
  ax2 = fig.add_subplot(222)
  ax3 = fig.add_subplot(223)
  ax4 = fig.add_subplot(224)

  heatmap(lists[0],ax1, labels[0:2])
  heatmap(lists[1],ax2, labels[2:4])
  heatmap(lists[2],ax3, labels[4:6])
  heatmap(lists[3],ax4, labels[6:8])
  # plt.show()

スクリーンショット 2022-11-15 20.17.46.png

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?