From 37c9ec615cb4765be9cf945e1d814cc8dbff7123 Mon Sep 17 00:00:00 2001 From: Marc Skov Madsen Date: Wed, 18 Sep 2024 22:31:27 +0200 Subject: [PATCH] tabulator gradients (#7291) Co-authored-by: Philipp Rudiger --- examples/reference/widgets/Tabulator.ipynb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/reference/widgets/Tabulator.ipynb b/examples/reference/widgets/Tabulator.ipynb index e478448f10..a95588f737 100644 --- a/examples/reference/widgets/Tabulator.ipynb +++ b/examples/reference/widgets/Tabulator.ipynb @@ -534,6 +534,27 @@ "styled" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can style your tables with gradients using the [`.text_gradient`](https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.text_gradient.html) or [`.background_gradient`](https://pandas.pydata.org/docs/reference/api/pandas.io.formats.style.Styler.background_gradient.html#pandas.io.formats.style.Styler.background_gradient) methods, along with [named Matplotlib color maps](https://matplotlib.org/stable/gallery/color/colormap_reference.html).\n", + "\n", + "**Note:** Styling with gradients requires Matplotlib to be installed." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "gradient_table = pn.widgets.Tabulator(style_df)\n", + "gradient_table.style.text_gradient(cmap=\"RdYlGn\", subset=[\"B\", \"C\"])\n", + "gradient_table.style.background_gradient(cmap=\"RdYlGn\", subset=[\"D\", \"E\"])\n", + "gradient_table" + ] + }, { "cell_type": "markdown", "metadata": {},