.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/ex2.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_ex2.py: ==================== Simple patheffect example ==================== .. GENERATED FROM PYTHON SOURCE LINES 7-51 .. image-sg:: /examples/images/sphx_glr_ex2_001.png :alt: ex2 :srcset: /examples/images/sphx_glr_ex2_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import mpl_visual_context.patheffects as pe from mpl_skia_pathops import PathOpsPathEffect # Fixing random state for reproducibility np.random.seed(19680) # Example data n = 4 """ ==================== another patheffect example ==================== """ x_pos = np.arange(n) performance = 5 * np.random.rand(n) colors = [f"C{i}" for i in range(n)] fig, ax = plt.subplots(num=1, clear=True) bars = ax.bar(x_pos, performance, align='center', alpha=0.7, color=colors) cb = pe.Clipboard() def get_path_from_cb(): path = cb["tpath"] affine = cb["affine"] return affine.transform_path(path) pe = [pe.RoundCorner(20, i_selector=lambda i: i in [2, 3]) | cb.copy() | pe.HLSModify(l=0.7), pe.RoundCorner(20, i_selector=lambda i: i in [2, 3]) | pe.Offset(5, -5) | PathOpsPathEffect.difference(get_path_from_cb, invert=True) | pe.GCModify(alpha=0.2), ] for p in bars[:]: p.set_path_effects(pe) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.054 seconds) .. _sphx_glr_download_examples_ex2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: ex2.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: ex2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: ex2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_