@@ -43,6 +43,32 @@ class __getattr__:
43
43
'toolbar' , 'timezone' , 'figure.max_open_warning' ,
44
44
'figure.raise_window' , 'savefig.directory' , 'tk.window_focus' ,
45
45
'docstring.hardcopy' , 'date.epoch' }
46
+ _DEPRECATED_SEABORN_STYLES = {
47
+ s : s .replace ("seaborn" , "seaborn-v0_8" )
48
+ for s in [
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." )
46
72
47
73
48
74
def _remove_blacklisted_style_params (d , warn = True ):
@@ -113,31 +139,9 @@ def use(style):
113
139
def fix_style (s ):
114
140
if isinstance (s , str ):
115
141
s = style_alias .get (s , s )
116
- if s in [
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
+ if s in _DEPRECATED_SEABORN_STYLES :
143
+ _api .warn_deprecated ("3.6" , message = _DEPRECATED_SEABORN_MSG )
144
+ s = _DEPRECATED_SEABORN_STYLES [s ]
141
145
return s
142
146
143
147
for style in map (fix_style , styles ):
@@ -244,17 +248,26 @@ def update_nested_dict(main_dict, new_dict):
244
248
return main_dict
245
249
246
250
251
+ class _StyleLibrary (dict ):
252
+ def __getitem__ (self , key ):
253
+ if key in _DEPRECATED_SEABORN_STYLES :
254
+ _api .warn_deprecated ("3.6" , message = _DEPRECATED_SEABORN_MSG )
255
+ key = _DEPRECATED_SEABORN_STYLES [key ]
256
+
257
+ return dict .__getitem__ (self , key )
258
+
259
+
247
260
# Load style library
248
261
# ==================
249
262
_base_library = read_style_directory (BASE_LIBRARY_PATH )
250
- library = None
263
+ library = _StyleLibrary ()
251
264
available = []
252
265
253
266
254
267
def reload_library ():
255
268
"""Reload the style library."""
256
- global library
257
- library = update_user_library (_base_library )
269
+ library . clear ()
270
+ library . update ( update_user_library (_base_library ) )
258
271
available [:] = sorted (library .keys ())
259
272
260
273
0 commit comments