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

Commit06c92b8

Browse files
committed
Rename outdated seaborn styles.
They are kept available under a versioned name for backcompat.
1 parentfd51e05 commit06c92b8

20 files changed

+51
-6
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
seaborn styles renamed
2+
~~~~~~~~~~~~~~~~~~~~~~
3+
Matplotlib currently ships many style files inspired from the seaborn
4+
library ("seaborn", "seaborn-bright", "seaborn-colorblind", etc.) but they
5+
have gone out of sync with the library itself since the release of seaborn
6+
0.9. To prevent confusion, the style files have been renamed "seaborn0.8",
7+
"seaborn0.8-bright", "seaborn0.8-colorblind", etc. Users are encouraged to
8+
directly use seaborn to access the up-to-date styles.

‎lib/matplotlib/style/core.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,45 @@ def use(style):
102102
103103
%s
104104
"""
105-
style_alias= {'mpl20':'default',
106-
'mpl15':'classic'}
107105
ifisinstance(style, (str,Path))orhasattr(style,'keys'):
108106
# If name is a single str, Path or dict, make it a single element list.
109107
styles= [style]
110108
else:
111109
styles=style
112110

113-
styles= (style_alias.get(s,s)ifisinstance(s,str)elses
114-
forsinstyles)
115-
forstyleinstyles:
111+
style_alias= {'mpl20':'default','mpl15':'classic'}
112+
113+
deffix_style(s):
114+
ifisinstance(s,str):
115+
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 'seaborn0.8-<style>'. "
139+
"Alternatively, directly use the seaborn API instead.")
140+
s=s.replace("seaborn","seaborn0.8")
141+
returns
142+
143+
forstyleinmap(fix_style,styles):
116144
ifnotisinstance(style, (str,Path)):
117145
_apply_style(style)
118146
elifstyle=='default':

‎lib/matplotlib/tests/test_style.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,12 @@ def test_xkcd_cm():
174174
withplt.xkcd():
175175
assertmpl.rcParams["path.sketch"]== (1,100,2)
176176
assertmpl.rcParams["path.sketch"]isNone
177+
178+
179+
deftest_deprecated_seaborn_styles():
180+
withmpl.style.context("seaborn0.8-bright"):
181+
seaborn_bright=mpl.rcParams.copy()
182+
assertmpl.rcParams!=seaborn_bright
183+
withpytest.warns(mpl._api.MatplotlibDeprecationWarning):
184+
mpl.style.use("seaborn-bright")
185+
assertmpl.rcParams==seaborn_bright

‎tutorials/colors/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def demo(sty):
134134

135135

136136
demo('default')
137-
demo('seaborn')
137+
demo('seaborn0.8')
138138

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp