

.. _sphx_glr_gallery_images_contours_and_fields_image_clip_path.py:


============================
Clipping images with patches
============================

Demo of image that's been clipped by a circular patch.




.. image:: /gallery/images_contours_and_fields/images/sphx_glr_image_clip_path_001.png
    :align: center





.. code-block:: python

    import matplotlib.pyplot as plt
    import matplotlib.patches as patches
    import matplotlib.cbook as cbook


    with cbook.get_sample_data('grace_hopper.png') as image_file:
        image = plt.imread(image_file)

    fig, ax = plt.subplots()
    im = ax.imshow(image)
    patch = patches.Circle((260, 200), radius=200, transform=ax.transData)
    im.set_clip_path(patch)

    ax.axis('off')
    plt.show()

**Total running time of the script:** ( 0 minutes  0.362 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: image_clip_path.py <image_clip_path.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: image_clip_path.ipynb <image_clip_path.ipynb>`

.. rst-class:: sphx-glr-signature

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
