> For the complete documentation index, see [llms.txt](https://zpliu.gitbook.io/booknote/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zpliu.gitbook.io/booknote/python/matplotlib/re-tu.md).

# imshow绘制热图

```bash
#输入数据为pandas数据框
from matplotlib import pyplot as plt
#! figure size
fig,ax=plt.subplots(figsize=(10,8))
#! theme chose
im=ax.imshow(spearmanr_dataFrame)
```

其中，X变量存储图像，可以是浮点型数组、unit8数组以及PIL图像，如果其为数组，则需满足一下形状： (1) M*N 此时数组必须为浮点型，其中值为该坐标的灰度； (2) M*N*3 RGB（浮点型或者unit8类型） (3) M*N\*4 RGBA（浮点型或者unit8类型）

## 添加图例

* `shrink=0.5`设置图例长度为图片的一半

```bash
#添加图例
fig.colorbar(im,shrink=0.5)
```
