@@ -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+ 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." )
4672
4773
4874def _remove_blacklisted_style_params (d , warn = True ):
@@ -113,31 +139,9 @@ def use(style):
113139 def fix_style (s ):
114140 if isinstance (s , str ):
115141 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 ]
141145 return s
142146
143147 for style in map (fix_style , styles ):
@@ -244,17 +248,26 @@ def update_nested_dict(main_dict, new_dict):
244248 return main_dict
245249
246250
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+
247260# Load style library
248261# ==================
249262_base_library = read_style_directory (BASE_LIBRARY_PATH )
250- library = None
263+ library = _StyleLibrary ()
251264available = []
252265
253266
254267def reload_library ():
255268 """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 ) )
258271 available [:] = sorted (library .keys ())
259272
260273
0 commit comments