.. _images_contours_and_fields-image_demo_clip_path:

images_contours_and_fields example code: image_demo_clip_path.py
================================================================



.. plot:: /home/tcaswell/source/p/matplotlib/doc/mpl_examples/images_contours_and_fields/image_demo_clip_path.py

::

    """
    Demo of image that's been clipped by a circular patch.
    """
    import matplotlib.pyplot as plt
    import matplotlib.patches as patches
    import matplotlib.cbook as cbook
    
    
    image_file = cbook.get_sample_data('grace_hopper.png')
    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()
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)