Add title to

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 = [
], ‘leiden’, n_pcs=23)
ax1 =, 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’)

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

This is a small and annoying issue of missing documentation: 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.

Thank you very much for your guidance!