-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default theme configuration to Plot (#3223)
* Improve Plot.theme docstring * First pass at Plot.config and Plot.config.theme * Validate rc params in Plot.theme * Add documentation for Plot.config.theme * Restrict Plot.theme.config.update to 'style' groups * Add docstrings for Plot.config objects * Clean up notebook * Fix notebook * Add type hints
- Loading branch information
Showing
6 changed files
with
385 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "a38a6fed-51de-4dbc-8d5b-4971d06acf2e", | ||
"metadata": { | ||
"tags": [ | ||
"hide" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import seaborn.objects as so" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "38081259-9382-4623-8d67-09aa114e0949", | ||
"metadata": {}, | ||
"source": [ | ||
"Theme configuration\n", | ||
"^^^^^^^^^^^^^^^^^^^\n", | ||
"\n", | ||
"The theme is a dictionary of matplotlib `rc parameters <https://matplotlib.org/stable/tutorials/introductory/customizing.html>`_. You can set individual parameters directly:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "34ca0ce9-5284-47b6-8281-180709dbec89", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"so.Plot.config.theme[\"axes.facecolor\"] = \"white\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "b3f93646-8370-4c16-ace4-7bb811688758", | ||
"metadata": {}, | ||
"source": [ | ||
"To change the overall style of the plot, update the theme with a dictionary of parameters, perhaps from one of seaborn's theming functions:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8e5eb7d3-cc7a-4231-b887-db37045f3db4", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from seaborn import axes_style\n", | ||
"so.Plot.config.theme.update(axes_style(\"whitegrid\"))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "f7c7bd9c-722d-45db-902a-c2dcdef571ee", | ||
"metadata": {}, | ||
"source": [ | ||
"To sync :class:`Plot` with matplotlib's global state, pass the `rcParams` dictionary:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "fd1cd96e-1a2c-474a-809f-20b8c4794578", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import matplotlib as mpl\n", | ||
"so.Plot.config.theme.update(mpl.rcParams)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "7e305ec1-4a83-411f-91df-aee2ec4d1806", | ||
"metadata": {}, | ||
"source": [ | ||
"The theme can also be reset back to seaborn defaults:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e3146b1d-1b5e-464f-a631-e6d6caf161b3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"so.Plot.config.theme.reset()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"id": "eae5da42-cf7f-41c9-b13d-8fa25e5cf0be", | ||
"metadata": {}, | ||
"source": [ | ||
"Changes made through this interface will apply to all subsequent :class:`Plot` instances. Use the :meth:`Plot.theme` method to modify the theme on a plot-by-plot basis." | ||
] | ||
} | ||
], | ||
"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.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.