.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_rc_context.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_plot_rc_context.py: Scoped Overrides with rc_context ================================ :func:`~memeplotlib.rc_context` mirrors :func:`matplotlib.rc_context` — apply config changes only inside a ``with`` block, then auto-restore the prior values on exit. .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: Python import memeplotlib as memes .. GENERATED FROM PYTHON SOURCE LINES 13-17 Scoping a custom palette ------------------------ Inside the block, any meme call uses the temporarily-overridden config. .. GENERATED FROM PYTHON SOURCE LINES 17-26 .. code-block:: Python memes.config["color"] = "white" # global default with memes.rc_context({"color": "yellow", "font": "comic"}): memes.meme("buzz", "yellow comic", "(scoped)") # Outside the block, the original "white" default is restored. assert memes.config["color"] == "white" .. image-sg:: /auto_examples/images/sphx_glr_plot_rc_context_001.png :alt: plot rc context :srcset: /auto_examples/images/sphx_glr_plot_rc_context_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 27-32 Setting individual keys ----------------------- ``config`` itself is a :class:`~memeplotlib.MemeplotlibConfig` mapping — treat it like ``matplotlib.rcParams``. .. GENERATED FROM PYTHON SOURCE LINES 32-39 .. code-block:: Python memes.config["fontsize"] = 96 memes.config["style"] = "lower" memes.meme("buzz", "Lowercase Memes", "Everywhere") # Reset back to the shipped defaults at the end of the example. memes.config.reset() .. image-sg:: /auto_examples/images/sphx_glr_plot_rc_context_002.png :alt: plot rc context :srcset: /auto_examples/images/sphx_glr_plot_rc_context_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.868 seconds) .. _sphx_glr_download_auto_examples_plot_rc_context.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_rc_context.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_rc_context.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_rc_context.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_