Pass the desired sub-DataFrame to seaborn.heatmap :
seaborn.heatmap(df[[col1, col2]], ...)
df[[col1, col2, ..., coln]] returns a DataFrame consisting of columns col1 , col2 , ... coln from df . Pay attention to double brackets.
If you want to select only certain values ββand build a graphics card, as if all other values ββwere zero, you can make a copy of the DataFrame and set these values ββto zero before calling heatmap . For example, by changing the example from the documents ,
import numpy as np import matplotlib.pyplot as plt import seaborn as sns import seaborn.matrix as smatrix sns.set() flights_long = sns.load_dataset("flights") flights = flights_long.pivot("month", "year", "passengers") flights = flights.reindex(flights_long.iloc[:12].month) columns = [1953,1955] myflights = flights.copy() mask = myflights.columns.isin(columns) myflights.loc[:, ~mask] = 0 arr = flights.values vmin, vmax = arr.min(), arr.max() sns.heatmap(myflights, annot=True, fmt="d", vmin=vmin, vmax=vmax) plt.show()
gives

source share