{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Styling a Table" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "By supplying keywords to the Table you can adjust its style:\n", "\n", "```python\n", "\"\"\"\n", "Args:\n", " df (pd.DataFrame):\n", " A pandas DataFrame with your table data\n", " ax (mpl.axes.Axes, optional):\n", " matplotlib axes. Defaults to None.\n", " index_col (str, optional):\n", " column to set as the DataFrame index. Defaults to None.\n", " columns (List[str], optional):\n", " columns to use. If None defaults to all columns.\n", " column_definitions (List[plottable.column_def.ColumnDefinition], optional):\n", " ColumnDefinitions for columns that should be styled. Defaults to None.\n", " textprops (Dict[str, Any], optional):\n", " textprops are passed to each TextCells matplotlib.pyplot.text. Defaults to {}.\n", " cell_kw (Dict[str, Any], optional):\n", " cell_kw are passed to to each cells matplotlib.patches.Rectangle patch.\n", " Defaults to {}.\n", " col_label_cell_kw (Dict[str, Any], optional):\n", " col_label_cell_kw are passed to to each ColumnLabels cells\n", " matplotlib.patches.Rectangle patch. Defaults to {}.\n", " col_label_divider (bool, optional):\n", " Whether to plot a divider line below the column labels. Defaults to True.\n", " col_label_divider_kw (Dict[str, Any], optional):\n", " col_label_divider_kw are passed to plt.plot. Defaults to {}.\n", " footer_divider (bool, optional):\n", " Whether to plot a divider line below the table. Defaults to False.\n", " footer_divider_kw (Dict[str, Any], optional):\n", " footer_divider_kw are passed to plt.plot. Defaults to {}.\n", " row_dividers (bool, optional):\n", " Whether to plot divider lines between rows. Defaults to True.\n", " row_divider_kw (Dict[str, Any], optional):\n", " row_divider_kw are passed to plt.plot. Defaults to {}.\n", " column_border_kw (Dict[str, Any], optional):\n", " column_border_kw are passed to plt.plot. Defaults to {}.\n", " even_row_color (str | Tuple, optional):\n", " facecolor of the even row cell's patches\n", " odd_row_color (str | Tuple, optional):\n", " facecolor of the even row cell's patches\n", "\"\"\"\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Column Definitions\n", "\n", "You can pass a list of `ColumnDefinition`'s to the column_definitions argument. \n", "\n", "```{seealso}\n", "How to use ColumnDefinition is documented in the [Using ColumnDefinition Notebook](./column_definition.ipynb)\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Textprops\n", "\n", "With `textprops` such as `fontsize`, `fontname` and `color` you can adjust the appearance of table text globally for the whole table. They are passed to all cell's texts and only overridden by a `ColumnDefinition`'s textprops." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cell Keywords\n", "\n", "With `cell_kw` such as `facecolor`, `edgecolor` and `linewidth` you can adjust the appearance of table cells globally. They are passed to all cell's rectangle patches.\n", "\n", "With `col_label_cell_kw` you can similarly adjust the appearance of the column label cells." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Row Divider Lines\n", "\n", "With boolean arguments `col_label_divider`, `footer_divider` and `row_dividers` you can plot divider lines between table rows.\n", "\n", "By passing arguments to their respective keyword arguments - `col_label_divider_kw`, `footer_divider_kw` and `row_dividers_kw` - you can further style the divider lines. Keywords are passed to `plt.plot`.\n", "\n", "## Column Border Keywords\n", "\n", "Similarly you can pass a `column_border_kw` dictionary to `Table` to style the vertical divider lines between `Column`'s. Keywords are passed to `plt.plot`.\n", "\n", "```{tip}\n", "Mind that they are only applied to `Column`'s that have a `border` attribute specified in their `ColumnDefinition`. \n", "You can find an example of plotting column borders in the [Women's World Cup Example](../example_notebooks/wwc_example.ipynb)\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Row Colors\n", "\n", "With the `even_row_color` and `odd_row_color` arguments you can color each respective rows cell colors with the color you passed.\n", "\n", "```{seealso}\n", "You can find an example in the [Basic Example Notebook](../example_notebooks/basic_example.ipynb)\n", "```" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.5 ('env': venv)", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.10.5" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "fad163352f6b6c4f05b9b8d41b1f28c58b235e61ec56c8581176f01128143b49" } } }, "nbformat": 4, "nbformat_minor": 2 }