2015-12-14 13 views
6

Biorąc pod uwagę następującą mapę cieplną, w jaki sposób usunąć tytuły osi ("miesiąc" i "rok")?Ukryj tytuły osi w Seaborn

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 graph

Odpowiedz

10

Przed skontaktowaniem sns.heatmap, dostać osie wykorzystujące plt.subplots, a następnie użyć set_xlabel i set_ylabel. Na przykład:

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 graph