首页 > 解决方案 > matplotlib:如何添加像素值范围的图例?

问题描述

我正在尝试使用以下代码可视化图像。如何在此图像中添加图例以表示像素的值范围?

first_layer_activation = activations[31]
print(first_layer_activation.shape)

结果:(1, 16, 16, 1)

import matplotlib.pyplot as plt
plt.matshow(first_layer_activation[0, :, :, 0], aspect='auto', cmap='viridis')

在此处输入图像描述

标签: pythonmatplotlib

解决方案


你的意思是这样的plt.colorbar()吗?


推荐阅读