.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/path_effects/demo_gradient.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_demo_gradient.py: ======================== Gradient & AlphaGradient ======================== .. GENERATED FROM PYTHON SOURCE LINES 7-47 .. image-sg:: /examples/path_effects/images/sphx_glr_demo_gradient_001.png :alt: demo gradient :srcset: /examples/path_effects/images/sphx_glr_demo_gradient_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mpl_visual_context.patheffects import (Gradient, AlphaGradient) from mpl_visual_context.patheffects import (StrokeOnly, StrokeColor, FillColor, GCModify) from matplotlib.patheffects import Normal fig, ax = plt.subplots(num=1, clear=True) t1 = ax.text(0.5, 0.2, "ImageBox", size=60, color="g", va="center", ha="center") t2 = ax.text(0.5, 0.5, "ImageBox", size=60, color="g", va="center", ha="center") t3 = ax.text(0.5, 0.8, "ImageBox", size=60, color="g", va="center", ha="center") t1.set_path_effects([ AlphaGradient("up"), ]) t2.set_path_effects([ GCModify(linewidth=15) | StrokeColor("k") | StrokeOnly(), GCModify(linewidth=7) | StrokeColor("w") | StrokeOnly(), Gradient("right"), ]) t3.set_path_effects([ GCModify(linewidth=5) | StrokeColor("k") | StrokeOnly(), FillColor("w"), Gradient("right", "up", cmap="rainbow"), ]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.139 seconds) .. _sphx_glr_download_examples_path_effects_demo_gradient.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_gradient.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_gradient.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_gradient.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_