Hide axis headers in Siborn

Given the following heat map, how would I remove the axis headers ("month" and "year")?

import seaborn as sns # Load the example flights dataset and conver to long-form flights_long = sns.load_dataset("flights") flights = flights_long.pivot("month", "year", "passengers") # Draw a heatmap with the numeric values in each cell sns.heatmap(flights, annot=True, fmt="d", linewidths=.5) 

current schedule

+6
source share
1 answer

Before calling sns.heatmap , get the axes using plt.subplots , then use set_xlabel and set_ylabel . For instance:

 import seaborn as sns import matplotlib.pyplot as plt # Load the example flights dataset and conver to long-form flights_long = sns.load_dataset("flights") flights = flights_long.pivot("month", "year", "passengers") # ADDED: Extract axes. fig, ax = plt.subplots(1, 1, figsize = (15, 15), dpi=300) # Draw a heatmap with the numeric values in each cell sns.heatmap(flights, annot=True, fmt="d", linewidths=.5) # ADDED: Remove labels. ax.set_ylabel('') ax.set_xlabel('') 

New chart

+10
source

All Articles