Add default theme configuration to Plot #3223
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a mechanism for changing the appearance of all plots made with
so.Plot
. It adds a configuration interface, accessible throughso.Plot.config
(this is an attribute of the class, not an instance). I expect to add a number of configuration objects; this PR addsso.Plot.config.theme
, which exposes a dictionary of rcParams that will be used by default in allPlot
plots, unless overridden byso.Plot().theme()
. So to change the appearance of all plots, you could put at the top of your notebook:then do
To use the matplotlib globals (whether determined by a
matplotlibrc
file or functions that modify the global state, you'd only need do)I've added a nice
_repr_html_
for the theme config object, so you can see the available parameters and what they're set to more easily:(One could even imaging making this an editable table for interactive updating. We'll see...)
Also, we actually store the theme defaults in a matplotlib
RcParams
object, so we get to take advantage of their validation:One possibility that I'm undecided on is whether there should be more direct access to seaborn's named themes, i.e. something like
I'm a little unsure of how/where best to document this, but for now I'm adding a configuration section right on the
Plot
API docs page.cf. #3005