top of page

[Python] Give a title to the colorbar with Seaborn heatmap


Overview


When you create a heatmap with seaborn, you also want to give a title to the color bar.

This time, I will introduce how to do it.



Method


Do as follows.

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

x=np.random.randint(0, 10, (8, 8))

fig, ax=plt.subplots()
ax=sns.heatmap(x)
ax.collections[0].colorbar.set_label('Colorbar Label')
plt.show()


Properties can be changed with the argument of set_label ().

//omit

ax.collections[0].colorbar.set_label('Colorbar Label', labelpad=20, fontsize=14)

//omit

Recent Posts

See All

[Python] Output pandas.DataFrame as json

Summary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in pandas.DataFrame format. I want to output this result to a file in j

[Python] Conditionally fitting

Overview If you want to do fitting, you can do it with scipy.optimize.leastsq etc. in python. However, when doing fitting, there are many cases where you want to condition the fitting parameters. For

댓글


Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page