python add labels to seaborn heatmap

Solutions on MaxInterview for python add labels to seaborn heatmap by the best coders in the world

showing results for - "python add labels to seaborn heatmap"
Madonna
06 Jan 2020
1# Basic syntax:
2sns.heatmap(df, xticklabels=x_labels, yticklabels=y_labels)
3
4# Example usage:
5import seaborn as sns
6flight = sns.load_dataset('flights') 	# Load flights datset from GitHub
7										# seaborn repository
8
9# Reshape flights dataeset to create seaborn heatmap
10flights_df = flight.pivot('month', 'year', 'passengers') 
11
12x_labels = [1,2,3,4,5,6,7,8,9,10,11,12] # Labels for x-axis
13y_labels = [11,22,33,44,55,66,77,88,99,101,111,121] # Labels for y-axis
14
15# Create seaborn heatmap with required labels
16sns.heatmap(flights_df, xticklabels=x_labels, yticklabels=y_labels)