# Add title to scanpy.pl.heatmap

**URL:** <https://discourse.scverse.org/t/add-title-to-scanpy-pl-heatmap/644>\
**Category:** scanpy\
**Created:** [July 26, 2022, 5:22am UTC](https://discourse.scverse.org/t/add-title-to-scanpy-pl-heatmap/644 "2022-07-26T05:22:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seigfried](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/seigfried/32/331_2.png) [@seigfried](https://discourse.scverse.org/u/seigfried)\
**Post date:** [July 26, 2022, 5:22am UTC](https://discourse.scverse.org/t/add-title-to-scanpy-pl-heatmap/644/1 "2022-07-26T05:22:57Z")

</div>

Hello  
I am trying to learn how to add elements to scanpy plots for example, adding a title to a heatmap. Is there a way to do this?

from matplotlib import pyplot as plt

marker\_genes\_dict = [  
“EPCAM”,“KRT8”,“KRT9”  
]

sc.tl.dendrogram(adata\_epi\_subset, ‘leiden’, n\_pcs=23)  
ax1 = sc.pl.heatmap(adata\_epi\_subset, marker\_genes\_dict, groupby=‘leiden’, show\_gene\_labels=False, vmin=-4, vmax=4, cmap=‘RdBu\_r’, dendrogram=True, use\_raw=True, swap\_axes=True, figsize=(5,5))

#ax1.set(title=‘Test’, ylabel=‘Test2’)  
#ax1.title(“z”)

AttributeError: ‘NoneType’ object has no attribute ‘title’

---

<div class="post-metadata">

**Author:** ![yotamcons](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/yotamcons/32/300_2.png) [@yotamcons](https://discourse.scverse.org/u/yotamcons)\
**Post date:** [July 28, 2022, 12:13pm UTC](https://discourse.scverse.org/t/add-title-to-scanpy-pl-heatmap/644/2 "2022-07-28T12:13:02Z")

</div>

This is a small and annoying issue of missing documentation:  
`sc.pl.heatmap` only returns something `if not show`, meaning if you pass `show=True`, and then it returns a **dictionary of axes,** from which you should select `ax1['heatmap_ax']`

For future incidents like this (and the way i figured the answer): you can follow the function to the actual code, and look at the `return` statement.

---

<div class="post-metadata">

**Author:** ![seigfried](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/seigfried/32/331_2.png) [@seigfried](https://discourse.scverse.org/u/seigfried)\
**Post date:** [July 29, 2022, 1:55am UTC](https://discourse.scverse.org/t/add-title-to-scanpy-pl-heatmap/644/3 "2022-07-29T01:55:38Z")

</div>

Thank you very much for your guidance!
