[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 AllSummary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in...
Phenomenon I get a title error when trying to import firestore with raspberry pi. from from firebase_admin import firestore ImportError:...
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...
Comments