Skip to content

Commit

Permalink
fixup! fixup! ENH: revive and update yt.funcs.matplotlib_style_contex…
Browse files Browse the repository at this point in the history
…t context manager
  • Loading branch information
neutrinoceros committed Feb 18, 2023
1 parent eefc839 commit 83d7b91
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions yt/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,23 +993,20 @@ def get_brewer_cmap(cmap):
return bmap.get_mpl_colormap(N=cmap[2])


def matplotlib_style_context(style=None, after_reset=False):
def matplotlib_style_context(style="yt.default", after_reset=False):
"""Returns a context manager for controlling matplotlib style.
Arguments are passed to matplotlib.style.context() if specified. Defaults
to setting "yt.default" style, after resetting to the default config parameters.
to setting yt's "yt.default" style, after resetting to the default config parameters.
"""
# FUTURE: this function should be deprecated in favour of matplotlib.style.context
# after support for matplotlib 3.6 and older versions is dropped.
import matplotlib.style

from yt.visualization._commons import MPL_VERSION

if style is None:
if MPL_VERSION >= Version("3.7"):
style = "yt.default"
else:
style = importlib_resources.files("yt") / "default.mplstyle"
if style == "yt.default" and MPL_VERSION < Version("3.7"):
style = importlib_resources.files("yt") / "default.mplstyle"

return matplotlib.style.context(style, after_reset=after_reset)

Expand Down

0 comments on commit 83d7b91

Please sign in to comment.