Skip to content

DOC: update styler user guide for new text_gradient #41661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions doc/source/user_guide/style.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@
" - [.highlight_min][minfunc] and [.highlight_max][maxfunc]: for use with identifying extremeties in data.\n",
" - [.highlight_between][betweenfunc] and [.highlight_quantile][quantilefunc]: for use with identifying classes within data.\n",
" - [.background_gradient][bgfunc]: a flexible method for highlighting cells based or their, or other, values on a numeric scale.\n",
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
" - [.text_gradient][textfunc]: similar method for highlighting text based on their, or other, values on a numeric scale.\n",
" - [.bar][barfunc]: to display mini-charts within cell backgrounds.\n",
" \n",
"The individual documentation on each function often gives more examples of their arguments.\n",
"\n",
Expand All @@ -1022,6 +1023,7 @@
"[betweenfunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_between.rst\n",
"[quantilefunc]: ../reference/api/pandas.io.formats.style.Styler.highlight_quantile.rst\n",
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst\n",
"[barfunc]: ../reference/api/pandas.io.formats.style.Styler.bar.rst"
]
},
Expand Down Expand Up @@ -1098,14 +1100,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### Background Gradient"
"### Background Gradient and Text Gradient"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can create \"heatmaps\" with the `background_gradient` method. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
"You can create \"heatmaps\" with the `background_gradient` and `text_gradient` methods. These require matplotlib, and we'll use [Seaborn](https://stanford.edu/~mwaskom/software/seaborn/) to get a nice colormap."
]
},
{
Expand All @@ -1120,19 +1122,31 @@
"df2.style.background_gradient(cmap=cm)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df2.style.text_gradient(cmap=cm)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[.background_gradient][bgfunc] has a number of keyword arguments to customise the gradients and colors. See its documentation.\n",
"[.background_gradient][bgfunc] and [.text_gradient][textfunc] have a number of keyword arguments to customise the gradients and colors. See the documentation.\n",
"\n",
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst"
"[bgfunc]: ../reference/api/pandas.io.formats.style.Styler.background_gradient.rst\n",
"[textfunc]: ../reference/api/pandas.io.formats.style.Styler.text_gradient.rst"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Set properties\n",
"\n",
"Use `Styler.set_properties` when the style doesn't actually depend on the values. This is just a simple wrapper for `.applymap` where the function returns the same properties for all cells."
]
},
Expand Down