FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Rename outdated seaborn styles. by anntzer · Pull Request #22317 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .mplstyle  (16) .py  (3) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 8 additions & 0 deletions doc/api/next_api_changes/deprecations/22317-AL.rst
This file contains hidden or 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,8 @@
seaborn styles renamed
~~~~~~~~~~~~~~~~~~~~~~
Matplotlib currently ships many style files inspired from the seaborn
library ("seaborn", "seaborn-bright", "seaborn-colorblind", etc.) but they
have gone out of sync with the library itself since the release of seaborn
0.9. To prevent confusion, the style files have been renamed "seaborn0.8",
"seaborn0.8-bright", "seaborn0.8-colorblind", etc. Users are encouraged to
directly use seaborn to access the up-to-date styles.
38 changes: 33 additions & 5 deletions lib/matplotlib/style/core.py
This file contains hidden or 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
Expand Up @@ -102,17 +102,45 @@ def use(style):

%s
"""
style_alias = {'mpl20': 'default',
'mpl15': 'classic'}
if isinstance(style, (str, Path)) or hasattr(style, 'keys'):
# If name is a single str, Path or dict, make it a single element list.
styles = [style]
else:
styles = style

styles = (style_alias.get(s, s) if isinstance(s, str) else s
for s in styles)
for style in styles:
style_alias = {'mpl20': 'default', 'mpl15': 'classic'}

def fix_style(s):
if isinstance(s, str):
s = style_alias.get(s, s)
if s in [
"seaborn",
"seaborn-bright",
"seaborn-colorblind",
"seaborn-dark",
"seaborn-darkgrid",
"seaborn-dark-palette",
"seaborn-deep",
"seaborn-muted",
"seaborn-notebook",
"seaborn-paper",
"seaborn-pastel",
"seaborn-poster",
"seaborn-talk",
"seaborn-ticks",
"seaborn-white",
"seaborn-whitegrid",
]:
_api.warn_deprecated(
"3.6", message="The seaborn styles shipped by Matplotlib "
"are deprecated since %(since)s, as they no longer "
"correspond to the styles shipped by seaborn. However, "
"they will remain available as 'seaborn0.8-<style>'. "
"Alternatively, directly use the seaborn API instead.")
s = s.replace("seaborn", "seaborn0.8")
return s

for style in map(fix_style, styles):
if not isinstance(style, (str, Path)):
_apply_style(style)
elif style == 'default':
Expand Down
9 changes: 9 additions & 0 deletions lib/matplotlib/tests/test_style.py
This file contains hidden or 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
Expand Up @@ -174,3 +174,12 @@ def test_xkcd_cm():
with plt.xkcd():
assert mpl.rcParams["path.sketch"] == (1, 100, 2)
assert mpl.rcParams["path.sketch"] is None


def test_deprecated_seaborn_styles():
with mpl.style.context("seaborn0.8-bright"):
seaborn_bright = mpl.rcParams.copy()
assert mpl.rcParams != seaborn_bright
with pytest.warns(mpl._api.MatplotlibDeprecationWarning):
mpl.style.use("seaborn-bright")
assert mpl.rcParams == seaborn_bright
2 changes: 1 addition & 1 deletion tutorials/colors/colors.py
This file contains hidden or 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
Expand Up @@ -134,7 +134,7 @@ def demo(sty):


demo('default')
demo('seaborn')
demo('seaborn0.8')

###############################################################################
# The first color ``'C0'`` is the title. Each plot uses the second and third
Expand Down

Back | FazBrowse Home | New Git URL