使用 Matplotlib 设置 Seaborn 热图上色彩条的最大值


若要为 Seaborn 热图上的色彩条设置值,我们可以执行以下步骤:

  • 使用 numpy 创建随机数据。
  • 使用heatmap() 方法将矩形数据绘制为颜色编码矩阵。
  • 若要显示图,请使用show() 方法。

示例

import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
data = np.random.rand(4, 4)
ax = sns.heatmap(data, vmax=1)
plt.show()

输出

更新于:2021 年 5 月 7 日

554 次浏览

开启你的 职业生涯

通过完成课程获取认证

开始学习
广告
© . All rights reserved.