qis.plot_df_table

qis.plot_df_table(df, add_index_as_column=True, column_width=2.0, row_height=0.625, first_column_width=3.0, first_row_height=None, col_widths=None, rotation_for_columns_headers=None, rotation_for_text=None, transpose=False, index_column_name=' ', fontsize=10, header_color='#40466e', header_text_color='w', row_colors=('#f1f1f2', 'w'), edge_color='lightgray', bbox=(0, 0, 1, 1), header_column_id=0, header_row_id=0, left_aligned_first_col=False, var_format=None, title=None, heatmap_columns=None, heatmap_rows=None, heatmap_rows_columns=None, cmap='RdYlGn', special_rows_colors=None, special_columns_colors=None, data_colors=None, diagonal_color=None, rows_edge_lines=None, rows_edge_color='blue', columns_edge_lines=None, bold_font=False, linewidth=0.5, alpha=1.0, emply_column_names=False, ax=None, **kwargs)[source]

render a DataFrame as a matplotlib table, with optional per-cell colouring.

A table drawn as a figure rather than as text, so it composes into a multi-panel factsheet page beside the charts it summarises and exports into the same PDF. Values are formatted before they arrive, so this function lays out and colours; it does not compute.

The colouring arguments are what make it more than a grid. heatmap_columns shades down a column so ranks are visible without reading the numbers; special_rows_colors picks out a total or a benchmark row; rows_edge_lines separates groups.

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

Parameters:
  • df (DataFrame | Series) – values to render, already formatted as strings where display matters

  • add_index_as_column (bool) – draw the index as the leading column

  • column_width (float) – width of a data column, in the table’s own units

  • row_height (float) – height of a data row

  • first_column_width (float | None) – width of the leading column, usually wider because it holds names

  • first_row_height (float) – height of the header row. None follows row_height

  • col_widths (List[float]) – explicit width per column, overriding column_width

  • rotation_for_columns_headers (int) – rotation in degrees of the header text

  • rotation_for_text (int) – rotation in degrees of the cell text

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

  • index_column_name (str) – header of the index column. The default is a space, which leaves the corner cell visually empty without collapsing it

  • header_color (str) – fill colour of the header row

  • header_text_color (str) – text colour of the header row

  • row_colors (List[str]) – colours cycled down the data rows, giving the banded look

  • edge_color (str) – colour of the cell borders

  • bbox (Tuple[float]) – (x0, y0, width, height) of the table within the axis, in axis coordinates

  • header_column_id (int) – index of the column treated as a header

  • header_row_id (int) – index of the row treated as a header

  • left_aligned_first_col (bool) – left-align the leading column, which reads better for names

  • heatmap_columns (List[int]) – positions of columns to colour by value down the column

  • heatmap_rows (List[int]) – positions of rows to colour by value across the row

  • heatmap_rows_columns (Tuple[Tuple[int, int], Tuple[int, int]]) – (rows, columns) block coloured on its own joint scale

  • cmap (str) – colour map for the heatmap regions

  • special_rows_colors (List[Tuple[int, str]]) – (position, colour) pairs overriding the banding for a row

  • special_columns_colors (List[Tuple[int, str]]) – (position, colour) pairs overriding the banding for a column

  • data_colors (List[Tuple[float, float, float]]) – explicit colour per cell, same shape as the data

  • diagonal_color (str) – fill for the leading diagonal, for a correlation or transition matrix

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

  • rows_edge_color (str) – colour of those separators

  • columns_edge_lines (List[Tuple[int, str]]) – positions after which to draw a vertical separator

  • bold_font (bool) – render all text bold

  • linewidth (float) – width of the cell borders

  • alpha (float) – cell opacity

  • emply_column_names (bool) – blank the header text while keeping the header row, for a table whose columns are labelled by an adjacent panel

  • fontsize (int)

  • var_format (str)

  • title (str)

  • ax (Axes)

Returns:

the figure drawn on, or None when ax was supplied or df is empty

Return type:

Figure | None