擅长:python、mysql、java
<p>可以将<a href="https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.tick_params.html" rel="noreferrer">matplotlib.axes.Axes.tick_params</a>与labelsize一起使用。</p>
<p>例如,使用labelsize 20的绘图:</p>
<pre><code>import seaborn as sns
import matplotlib.pyplot as plt
from numpy import arange
x = arange(25).reshape(5, 5)
cmap = sns.diverging_palette(220, 20, sep=20, as_cmap=True)
ax = sns.heatmap(x, cmap=cmap)
# use matplotlib.colorbar.Colorbar object
cbar = ax.collections[0].colorbar
# here set the labelsize by 20
cbar.ax.tick_params(labelsize=20)
plt.show()
</code></pre>
<p><a href="https://i.stack.imgur.com/stVZ6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/stVZ6.png" alt="enter image description here"/></a></p>
<p>我引用了以下答案:<br/>
-<a href="https://stackoverflow.com/questions/34820239/seaborn-heatmap-colorbar-label-as-percentage">Using matplotlib.colorbar.Colorbar object</a><br/>
-<a href="https://stackoverflow.com/questions/40184696/change-fontsize-of-colorbars-in-matplotlib">Setting parameter</a></p>