Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a title and axis labels to Seaborn Heatmap?

I want to add a title to a seaborn heatmap. Using Pandas and iPython Notebook

code is below,

a1_p = a1.pivot_table( index='Postcode', columns='Property Type', values='Count', aggfunc=np.mean, fill_value=0)  sns.heatmap(a1_p, cmap="YlGnBu") 

the data is pretty straight forward:

In [179]: a1_p  Out [179]: Property Type   Flat    Terraced house  Unknown Postcode             E1  11  0   0 E14 12  0   0 E1W 6   0   0 E2  6   0   0 
like image 230
Ammar Akhtar Avatar asked Sep 22 '15 18:09

Ammar Akhtar


People also ask

How do I add axis titles to Seaborn heatmap?

Use the set_title() Function to Add a Title to a Seaborn Plot. A seaborn plot returns a matplotlib axes instance type object. For such objects, we can use the set_title() function to add a title to the plot.

How do you title a heatmap?

Add Custom Title and Labels to Heatmap Load a sample of gene expression data. Display a heatmap of the gene expression values for 4918 genes from 78 samples. Add a title to the heatmap in red. title = addTitle(hmo,'Gene Expression Data','Color','red');

How do you give a title in Seaborn?

To add a title to a single seaborn plot, you can use the . set() function. To add an overall title to a seaborn facet plot, you can use the . suptitle() function.

How do I rename my axis in Seaborn?

We make use of the set_title(), set_xlabel(), and set_ylabel() functions to change axis labels and set the title for a plot.


1 Answers

heatmap is an axes-level function, so you should be able to use just plt.title or ax.set_title:

%matplotlib inline import numpy as np import os import seaborn as sns import matplotlib.pyplot as plt  data = np.random.randn(10,12)  ax = plt.axes() sns.heatmap(data, ax = ax)  ax.set_title('lalala') plt.show() 

enter image description here

like image 149
areuexperienced Avatar answered Sep 20 '22 23:09

areuexperienced