# 6.2.4 Advanced Heatmap

### 1. Basic Annotated Heatmap

```
## Annotated heatmap
import plotly.figure_factory as ff

z = [[.1, .3, .5, .7, .9],
     [1, .8, .6, .4, .2],
     [.2, 0, .5, .7, .9],
     [.9, .8, .4, .2, 0],
     [.3, .4, .5, .7, 1]]

fig = ff.create_annotated_heatmap(z)
fig.show()
```

![](https://998709212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB-ky7fVqjeXA6EcAbW%2F-MDAt11DQHk_LZDR0ClT%2F-MDAtlDwGcn9Mz-ANSzy%2FScreenshot%202020-07-26%20at%2018.04.28.png?alt=media\&token=1f967e59-b014-4405-a9d7-8c3d27a15e7f)

### 2. Heatmap with defined color-scale

```
z = [[.1, .3, .5, .7],
     [1.0, .8, .6, .4],
     [.6, .4, .2, 0.0],
     [.9, .7, .5, .3]]

colorscale = [[0, 'lightblue'], [1, 'navy']]
font_colors = ['white']
fig = ff.create_annotated_heatmap(z, colorscale=colorscale, font_colors=font_colors)

# Make text size larger
for i in range(len(fig.layout.annotations)):
    fig.layout.annotations[i].font.size = 16
fig.show()
```

![](https://998709212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB-ky7fVqjeXA6EcAbW%2F-MDAt11DQHk_LZDR0ClT%2F-MDAtnoE_NWZVWTPi7wi%2FScreenshot%202020-07-26%20at%2018.04.20.png?alt=media\&token=2735f8ea-ce64-4034-bad6-360fffa17fbf)

### 3. Customized Heatmap

```
z = [[.1, .3, .5],
     [1.0, .8, .6],
     [.6, .4, .2]]

x = ['Product A', 'Product B', 'Product C']
y = ['Game Three', 'Game Two', 'Game One']

z_text = [['Good', 'Bad', 'Good'],
          ['Good', 'Good', 'Bad'],
          ['Bad', 'Bad', 'Good']]

fig = ff.create_annotated_heatmap(z, x=x, y=y, annotation_text=z_text, colorscale='hot')
# Make text size larger
for i in range(len(fig.layout.annotations)):
    fig.layout.annotations[i].font.size = 16
fig.show()
```

![](https://998709212-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MB-ky7fVqjeXA6EcAbW%2F-MDAt11DQHk_LZDR0ClT%2F-MDAttrTiS9xz_y1Rz-_%2FScreenshot%202020-07-26%20at%2018.14.30.png?alt=media\&token=7086df0f-af20-49ed-9173-57cd5499eff6)
