.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/image_effect/text_image_effect.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_image_effect_text_image_effect.py: ==================== Image Effect ==================== .. GENERATED FROM PYTHON SOURCE LINES 7-69 .. image-sg:: /examples/image_effect/images/sphx_glr_text_image_effect_001.png :alt: text image effect :srcset: /examples/image_effect/images/sphx_glr_text_image_effect_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from matplotlib.patheffects import AbstractPathEffect, Normal from matplotlib import cbook import matplotlib.pyplot as plt from mpl_visual_context.patheffects import StrokeOnly, GCModify, ImageEffect from abc import abstractmethod fig, ax = plt.subplots(num=1, clear=True) t1 = ax.text( 0.5, 0.5, "M", size=100, color="y", weight="bold", va="center", ha="center", ) t2 = ax.text( 1.5, 0.5, "M", size=100, color="r", weight="bold", va="center", ha="center", ) ax.set_xlim(0, 2) from mpl_visual_context.image_effect import ( AlphaAxb, Pad, Fill, Dilation, Gaussian, Offset, ) import mpl_visual_context.patheffects as pe from mpl_visual_context.image_effect import LightSource, LightSourceSharp shadow = ImageEffect( AlphaAxb((0.3, 0)) | Pad(15) | Fill("k") | Dilation(2) | Gaussian(3) | Offset(5, -5) ) t1.set_path_effects([ shadow, ImageEffect(Pad(10) | LightSource(azdeg=215)) ]) t2.set_path_effects([ shadow, ImageEffect(Pad(10) | LightSourceSharp(azdeg=215)) ]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.071 seconds) .. _sphx_glr_download_examples_image_effect_text_image_effect.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: text_image_effect.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: text_image_effect.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: text_image_effect.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_