Please note that seaborn authors seaborn want seaborn.heatmap work with categorical data frames. This is not at all.
If your index and columns have numeric values ββand / or date and time values, this code will be useful to you.
The Matplotlib pcolormesh thermal display pcolormesh requires bins instead of indexes, so there is some fancy code to build bins from your data frame indexes (even if your index is not evenly spaced!).
The rest is just np.meshgrid and plt.pcolormesh .
import pandas as pd import numpy as np import matplotlib.pyplot as plt def conv_index_to_bins(index): """Calculate bins to contain the index values. The start and end bin boundaries are linearly extrapolated from the two first and last values. The middle bin boundaries are midpoints. Example 1: [0, 1] -> [-0.5, 0.5, 1.5] Example 2: [0, 1, 4] -> [-0.5, 0.5, 2.5, 5.5] Example 3: [4, 1, 0] -> [5.5, 2.5, 0.5, -0.5]""" assert index.is_monotonic_increasing or index.is_monotonic_decreasing
Call it using heatmap(df) and look using plt.show() .

OrangeSherbet Jul 01 '19 at 18:58 2019-07-01 18:58
source share