Skip to content

Instantly share code, notes, and snippets.

@mwaskom
Last active August 23, 2023 15:22
Show Gist options
  • Save mwaskom/60a888c8fcbe08837d185fc4a9f1a265 to your computer and use it in GitHub Desktop.
Save mwaskom/60a888c8fcbe08837d185fc4a9f1a265 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "3b291db3-dbff-4ec5-bbb0-f68535bb0261",
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"import matplotlib as mpl\n",
"from ipywidgets import interactive\n",
"from IPython.display import HTML, display"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c6fe3b38-bfaa-44a4-ab2b-92cb4fbe9254",
"metadata": {},
"outputs": [],
"source": [
"@interactive\n",
"def rcparam_viewer(search=\"\"):\n",
" rows = []\n",
" for key, val in mpl.rcParams.items():\n",
" try:\n",
" hit = search and bool(re.search(search, key))\n",
" except re.error:\n",
" hit = False\n",
" if not hit:\n",
" continue\n",
" try:\n",
" if val != mpl.rcParamsDefault[key]:\n",
" style = \"style='font-weight: bold'\"\n",
" else:\n",
" style = \"\"\n",
" except:\n",
" style = \"\"\n",
" rows.append(f\"<tr {style}><td>{key}</td><td style='text-align: left'>{val!r}</td></tr>\")\n",
" content = \"\".join(rows)\n",
" width, height = 700, 400\n",
" html = f\"<div style='height: {height}px; overflow-y: auto'><table>{content}</table></div>\"\n",
" display(HTML(html))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7f4b1056-3260-48c8-a7f2-7a05eb9adf18",
"metadata": {},
"outputs": [],
"source": [
"import seaborn as sns\n",
"sns.set_theme()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "726807df-821e-4d12-a028-46bba9c27e60",
"metadata": {},
"outputs": [],
"source": [
"rcparam_viewer"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6fb772d-bf26-4c78-bacb-80115c2bbed6",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "py310",
"language": "python",
"name": "py310"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment