Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c1f7e5

Browse files
committed
Restore (and warn on) seaborn styles in style.library
Fixes#24264
1 parente148998 commit0c1f7e5

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed

‎lib/matplotlib/style/core.py

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ class __getattr__:
4343
'toolbar','timezone','figure.max_open_warning',
4444
'figure.raise_window','savefig.directory','tk.window_focus',
4545
'docstring.hardcopy','date.epoch'}
46+
_DEPRECATED_SEABORN_STYLES= {
47+
s:s.replace("seaborn","seaborn-v0_8")
48+
forsin [
49+
"seaborn",
50+
"seaborn-bright",
51+
"seaborn-colorblind",
52+
"seaborn-dark",
53+
"seaborn-darkgrid",
54+
"seaborn-dark-palette",
55+
"seaborn-deep",
56+
"seaborn-muted",
57+
"seaborn-notebook",
58+
"seaborn-paper",
59+
"seaborn-pastel",
60+
"seaborn-poster",
61+
"seaborn-talk",
62+
"seaborn-ticks",
63+
"seaborn-white",
64+
"seaborn-whitegrid",
65+
]
66+
}
67+
_DEPRECATED_SEABORN_MSG= (
68+
"The seaborn styles shipped by Matplotlib are deprecated since %(since)s, "
69+
"as they no longer correspond to the styles shipped by seaborn. However, "
70+
"they will remain available as 'seaborn-v0_8-<style>'. Alternatively, "
71+
"directly use the seaborn API instead.")
4672

4773

4874
def_remove_blacklisted_style_params(d,warn=True):
@@ -113,31 +139,9 @@ def use(style):
113139
deffix_style(s):
114140
ifisinstance(s,str):
115141
s=style_alias.get(s,s)
116-
ifsin [
117-
"seaborn",
118-
"seaborn-bright",
119-
"seaborn-colorblind",
120-
"seaborn-dark",
121-
"seaborn-darkgrid",
122-
"seaborn-dark-palette",
123-
"seaborn-deep",
124-
"seaborn-muted",
125-
"seaborn-notebook",
126-
"seaborn-paper",
127-
"seaborn-pastel",
128-
"seaborn-poster",
129-
"seaborn-talk",
130-
"seaborn-ticks",
131-
"seaborn-white",
132-
"seaborn-whitegrid",
133-
]:
134-
_api.warn_deprecated(
135-
"3.6",message="The seaborn styles shipped by Matplotlib "
136-
"are deprecated since %(since)s, as they no longer "
137-
"correspond to the styles shipped by seaborn. However, "
138-
"they will remain available as 'seaborn-v0_8-<style>'. "
139-
"Alternatively, directly use the seaborn API instead.")
140-
s=s.replace("seaborn","seaborn-v0_8")
142+
ifsin_DEPRECATED_SEABORN_STYLES:
143+
_api.warn_deprecated("3.6",message=_DEPRECATED_SEABORN_MSG)
144+
s=_DEPRECATED_SEABORN_STYLES[s]
141145
returns
142146

143147
forstyleinmap(fix_style,styles):
@@ -244,17 +248,26 @@ def update_nested_dict(main_dict, new_dict):
244248
returnmain_dict
245249

246250

251+
class_StyleLibrary(dict):
252+
def__getitem__(self,key):
253+
ifkeyin_DEPRECATED_SEABORN_STYLES:
254+
_api.warn_deprecated("3.6",message=_DEPRECATED_SEABORN_MSG)
255+
key=_DEPRECATED_SEABORN_STYLES[key]
256+
257+
returndict.__getitem__(self,key)
258+
259+
247260
# Load style library
248261
# ==================
249262
_base_library=read_style_directory(BASE_LIBRARY_PATH)
250-
library=None
263+
library=_StyleLibrary()
251264
available= []
252265

253266

254267
defreload_library():
255268
"""Reload the style library."""
256-
globallibrary
257-
library=update_user_library(_base_library)
269+
library.clear()
270+
library.update(update_user_library(_base_library))
258271
available[:]=sorted(library.keys())
259272

260273

‎lib/matplotlib/tests/test_style.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def test_deprecated_seaborn_styles():
184184
withpytest.warns(mpl._api.MatplotlibDeprecationWarning):
185185
mpl.style.use("seaborn-bright")
186186
assertmpl.rcParams==seaborn_bright
187+
withpytest.warns(mpl._api.MatplotlibDeprecationWarning):
188+
mpl.style.library["seaborn-bright"]
187189

188190

189191
deftest_up_to_date_blacklist():

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp