Skip to content

Commit babe2cc

Browse files
committed
update user guide
1 parent 67b863b commit babe2cc

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/source/user_guide/style.ipynb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"source": [
5050
"import pandas as pd\n",
5151
"import numpy as np\n",
52+
"import matplotlib as mpl\n",
5253
"\n",
5354
"df = pd.DataFrame([[38.0, 2.0, 18.0, 22.0, 21, np.nan],[19, 439, 6, 452, 226,232]], \n",
5455
" index=pd.Index(['Tumour (Positive)', 'Non-Tumour (Negative)'], name='Actual Label:'), \n",
@@ -1275,9 +1276,9 @@
12751276
"cell_type": "markdown",
12761277
"metadata": {},
12771278
"source": [
1278-
"Additional keyword arguments give more control on centering and positioning, and you can pass a list of `[color_negative, color_positive]` to highlight lower and higher values.\n",
1279+
"Additional keyword arguments give more control on centering and positioning, and you can pass a list of `[color_negative, color_positive]` to highlight lower and higher values or a matplotlib colormap.\n",
12791280
"\n",
1280-
"Here's how you can change the above with the new `align` option, combined with setting `vmin` and `vmax` limits, the `width` of the figure, and underlying css `props` of cells, leaving space to display the text and the bars:"
1281+
"To showcase an example here's how you can change the above with the new `align` option, combined with setting `vmin` and `vmax` limits, the `width` of the figure, and underlying css `props` of cells, leaving space to display the text and the bars. We also use `text_gradient` to color the text the same as the bars using a matplotlib colormap (although in this case the visualization is probably better without this additional effect)."
12811282
]
12821283
},
12831284
{
@@ -1286,8 +1287,10 @@
12861287
"metadata": {},
12871288
"outputs": [],
12881289
"source": [
1289-
"df2.style.bar(align=0, vmin=-2.5, vmax=2.5, color=['#d65f5f', '#5fba7d'], height=50,\n",
1290-
" width=60, props=\"width: 120px; border-right: 1px solid black;\").format('{:.3f}', na_rep=\"\")"
1290+
"df2.style.format('{:.3f}', na_rep=\"\")\\\n",
1291+
" .bar(align=0, vmin=-2.5, vmax=2.5, color=mpl.cm.get_cmap(\"bwr\"), height=50,\n",
1292+
" width=60, props=\"width: 120px; border-right: 1px solid black;\")\\\n",
1293+
" .text_gradient(cmap=\"bwr\", vmin=-2.5, vmax=2.5)"
12911294
]
12921295
},
12931296
{
@@ -2031,7 +2034,7 @@
20312034
"name": "python",
20322035
"nbconvert_exporter": "python",
20332036
"pygments_lexer": "ipython3",
2034-
"version": "3.8.7"
2037+
"version": "3.8.6"
20352038
}
20362039
},
20372040
"nbformat": 4,

0 commit comments

Comments
 (0)