qis.plot_heatmap

qis.plot_heatmap(df, transpose=False, inverse=False, date_format='%Y', cmap='RdYlGn', var_format='{:.1%}', alpha=1.0, fontsize=10, title=None, top_x_label=True, square=False, vline_columns=None, hline_rows=None, vmin=None, vmax=None, labelpad=50, ylabel='', annot=True, ax=None, **kwargs)[source]

draw a DataFrame as a colour-coded table.

The colour carries the magnitude and the annotation carries the number, so the panel is readable both at a glance and exactly. vmin and vmax are what make several heatmaps comparable: without them each panel scales its colours to its own range and two charts side by side mislead.

Arguments shared with every plot_* function are documented in qis/docs/plotting_kwargs.md.

Parameters:
  • df (DataFrame) – values to colour, drawn in the orientation of the frame

  • transpose (bool) – swap rows and columns before drawing

  • inverse (bool) – reindex by reversed display-row labels; ignored when transpose is True

  • date_format (str | None) – strftime format for a DatetimeIndex on either axis

  • cmap (str | ListedColormap) – matplotlib colour map name, or an explicit map. The default is diverging, which suits a signed quantity centred near zero

  • alpha (float) – cell opacity

  • top_x_label (bool) – place the column labels above the table rather than below

  • square (bool) – force square cells, which a correlation matrix wants

  • vline_columns (List[int]) – positions after which to draw a vertical separator

  • hline_rows (List[int]) – positions after which to draw a horizontal separator

  • vmin (float) – value mapped to the low end of the colour scale. None takes the data minimum, so panels drawn separately are not comparable unless this is set

  • vmax (float) – value mapped to the high end of the colour scale

  • labelpad (int) – padding in points between the axis and its label

  • annot (bool | ndarray) – write the value in each cell. An array matching the input df shape supplies positional cell labels, which follow the data through transpose or row reversal. Rectangular transposed plots also accept arrays already matching the display shape. Use var_format=None for strings drawn over unformatted colours

  • var_format (str | None)

  • fontsize (int)

  • title (str | None)

  • ylabel (str)

  • ax (Axes)

Returns:

the figure drawn on, or None when ax was supplied

Return type:

Figure | None