Skip to content

Commit e030bcd

Browse files
authored
Merge pull request matplotlib#8949 from tacaswell/enh_name_defaults
ENH: add style aliases for 'default' and 'classic'
2 parents 3bf8dcc + 396083f commit e030bcd

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/matplotlib/style/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,18 @@ def use(style):
8989
9090
9191
"""
92+
style_alias = {'mpl20': 'default',
93+
'mpl15': 'classic'}
9294
if isinstance(style, six.string_types) or hasattr(style, 'keys'):
9395
# If name is a single str or dict, make it a single element list.
9496
styles = [style]
9597
else:
9698
styles = style
9799

100+
styles = (style_alias.get(s, s)
101+
if isinstance(s, six.string_types)
102+
else s
103+
for s in styles)
98104
for style in styles:
99105
if not isinstance(style, six.string_types):
100106
_apply_style(style)

lib/matplotlib/tests/test_style.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,18 @@ def test_context_with_badparam():
143143
with x:
144144
pass
145145
assert mpl.rcParams[PARAM] == other_value
146+
147+
148+
@pytest.mark.parametrize('equiv_styles',
149+
[('mpl20', 'default'),
150+
('mpl15', 'classic')],
151+
ids=['mpl20', 'mpl15'])
152+
def test_alias(equiv_styles):
153+
rc_dicts = []
154+
for sty in equiv_styles:
155+
with style.context(sty):
156+
rc_dicts.append(dict(mpl.rcParams))
157+
158+
rc_base = rc_dicts[0]
159+
for nm, rc in zip(equiv_styles[1:], rc_dicts[1:]):
160+
assert rc_base == rc

0 commit comments

Comments
 (0)