You are reading an old version of the documentation (v1.5.0). For the latest version see https://matplotlib.org/stable/

We're updating the default styles for Matplotlib 2.0

Learn what to expect in the new updates

matplotlib

Previous topic

images_contours_and_fields example code: image_demo.py

Next topic

images_contours_and_fields example code: interpolation_methods.py

This Page

images_contours_and_fields example code: image_demo_clip_path.pyΒΆ

(Source code, png, hires.png, pdf)

../../_images/image_demo_clip_path.png
"""
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)

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

Keywords: python, matplotlib, pylab, example, codex (see Search examples)