.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/path_effects/text-shadow.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_examples_path_effects_text-shadow.py: ==================== Demo with shadow path ==================== Inspired by the example in scientific visualization book by N. P. Rougier. .. GENERATED FROM PYTHON SOURCE LINES 8-31 .. image-sg:: /examples/path_effects/images/sphx_glr_text-shadow_001.png :alt: text shadow :srcset: /examples/path_effects/images/sphx_glr_text-shadow_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from matplotlib.patheffects import Normal from mpl_visual_context.patheffects import FillColor, AlphaGradient from mpl_visual_context.patheffects_shadow import ShadowPath import matplotlib.pyplot as plt red = np.array([233, 77, 85, 255]) / 255 darkred = np.array([130, 60, 71, 255]) / 255 fig, ax = plt.subplots(num=2, clear=True) t = ax.text(0.5, 0.5, "Matplotlib", ha="center", va="center", size=60, color="w", clip_on=True) t.set_path_effects([ShadowPath(45, 180) | FillColor(darkred) | AlphaGradient("0 ^ 0.1 ^ 0.3 ^ 0.5"), Normal(), ]) ax.patch.set_fc(red) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.109 seconds) .. _sphx_glr_download_examples_path_effects_text-shadow.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: text-shadow.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: text-shadow.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: text-shadow.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_