File: image_demo_clip_path.py

package info (click to toggle)
ipe-tools 1%3A7.2.29.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 836 kB
  • sloc: cpp: 2,719; python: 2,122; ansic: 1,053; sh: 224; makefile: 94; xml: 39
file content (15 lines) | stat: -rw-r--r-- 439 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""
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

datafile = cbook.get_sample_data('grace_hopper.jpg', asfileobj=False)
image = plt.imread(datafile)
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')