Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit edc6f3c

Browse files
committed
Add use_style func and style setting
1 parent c831910 commit edc6f3c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

‎proplot/config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def get_ipython():
3434
__all__ = [
3535
'rc', 'rc_configurator',
3636
'register_cmaps', 'register_cycles', 'register_colors', 'register_fonts',
37+
'config_inline_backend', 'use_style',
3738
'inline_backend_fmt', # deprecated
3839
]
3940

@@ -465,6 +466,11 @@ def _get_param_dicts(self, key, value):
465466
if key == 'inlinefmt':
466467
config_inline_backend(value)
467468

469+
# Special key: apply stylesheet
470+
elif key == 'style':
471+
if value is not None:
472+
kw_params, kw_added = _get_style_dicts(value, infer=True)
473+
468474
# Cycler
469475
elif key in ('cycle', 'rgbcycle'):
470476
colors = _update_color_cycle(key, value)
@@ -1163,6 +1169,29 @@ def _infer_added_params(kw_params):
11631169
return kw_added
11641170

11651171

1172+
def use_style(style):
1173+
"""
1174+
Apply the `matplotlib style(s) \
1175+
<https://matplotlib.org/tutorials/introductory/customizing.html>`__
1176+
with `matplotlib.style.use`. This function is
1177+
called when you modify the :rcraw:`style` property.
1178+
1179+
Parameters
1180+
----------
1181+
style : str, dict, or list thereof
1182+
The matplotlib style name(s) or stylesheet filename(s), or dictionary(s)
1183+
of settings. Use ``'default'`` to apply matplotlib default settings and
1184+
``'original'`` to include settings from your user ``matplotlibrc`` file.
1185+
"""
1186+
# NOTE: This function is not really necessary but makes proplot's
1187+
# stylesheet-supporting features obvious. Plus changing the style does
1188+
# so much *more* than changing rc params or quick settings, so it is
1189+
# nice to have dedicated function instead of just another rc_param name.
1190+
kw_params, kw_added = _get_style_dicts(style, infer=True)
1191+
rc_params.update(kw_params)
1192+
rc_added.update(kw_added)
1193+
1194+
11661195
@docstring.add_snippets
11671196
def register_cmaps(user=True, default=False):
11681197
"""

‎proplot/internals/defaults.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'share': 3,
4545
'small': 9,
4646
'span': True,
47+
'style': None,
4748
'tickdir': 'out',
4849
'ticklen': 4.0,
4950
'ticklenratio': 0.5,

0 commit comments

Comments
 (0)