.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/path_effects/text_outline.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_outline.py: ==================== Text w/ PathEffects ==================== .. GENERATED FROM PYTHON SOURCE LINES 7-62 .. image-sg:: /examples/path_effects/images/sphx_glr_text_outline_001.png :alt: text outline :srcset: /examples/path_effects/images/sphx_glr_text_outline_001.png :class: sphx-glr-single-img .. code-block:: Python # from the book import numpy as np import matplotlib.pyplot as plt fig = plt.figure(figsize=(8, 3)) ax = fig.add_axes([0, 0, 1, 1], frameon=True) # family = "Pacifico" text = "Matplotlib" t1 = ax.text( 0.5, 0.6, "Matplotlib", size=60, color="green", weight="bold", va="center", ha="center", ) t2 = ax.text( 0.5, 0.3, "mpl-visual-context", size=30, color="green", weight="bold", va="center", ha="center", ) from matplotlib.patheffects import Normal from mpl_visual_context.patheffects import GCModify, Offset, FillColor from mpl_visual_context.patheffects import Glow, CmapGlow cmap = plt.cm.viridis # cmap = plt.cm.magma pe1 = [ CmapGlow(cmap, diff_linewidth=10, alpha_line=1, xoffset=5, yoffset=-5), GCModify(foreground=cmap(0.0), linewidth=0.5) | FillColor(cmap(1.0)), ] pe2 = [ Offset(2, -2) | Glow(diff_linewidth=1.2), Offset(1, -1), FillColor("white"), ] t1.set_path_effects(pe1) t2.set_path_effects(pe2) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.074 seconds) .. _sphx_glr_download_examples_path_effects_text_outline.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: text_outline.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: text_outline.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: text_outline.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_