.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/apply_config.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_apply_config.py: Apply Config Example ===================================== :func:`sysplot.apply_config` applies a seaborn-derived theme globally to all subsequent Matplotlib figures. Font size, line width, x-margin, and seaborn style can be customised via :class:`sysplot.SysplotConfig`, overridden individually, or reset to defaults with :func:`sysplot.reset_config`. .. GENERATED FROM PYTHON SOURCE LINES 9-39 .. image-sg:: /_auto_examples/images/sphx_glr_apply_config_001.png :alt: apply_config() :srcset: /_auto_examples/images/sphx_glr_apply_config_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none active font_size: 12 active xmargin: 0.05 | .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import sysplot as ssp # Create and validate a custom configuration. config = ssp.SysplotConfig(font_size=12, linewidth=1.5, seaborn_style="ticks") config.validate() # Apply the full config object. ssp.apply_config(config=config) # You can still override selected fields directly. ssp.apply_config(xmargin=0.05) # Inspect active values. current = ssp.get_config() print("active font_size:", current.font_size) print("active xmargin:", current.xmargin) x = np.linspace(0, 2 * np.pi, 200) fig, ax = plt.subplots() ax.plot(x, np.sin(x), label="sin(x)") ax.plot(x, np.cos(x), label="cos(x)") ax.set(title="apply_config()", xlabel="x", ylabel="y") ax.legend() plt.show() # Optionally restore defaults for later plots. ssp.reset_config() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.241 seconds) .. _sphx_glr_download__auto_examples_apply_config.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: apply_config.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: apply_config.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: apply_config.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_