备注
Go to the end to download the full example code..
用补丁裁剪图像#
演示被圆形补丁裁剪的图像.
import matplotlib.pyplot as plt
import matplotlib.cbook as cbook
import matplotlib.patches as patches
with cbook.get_sample_data('grace_hopper.jpg') 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()

参考
以下函数,方法,类和模块的用法在本例中显示:
matplotlib.axes.Axes.imshow/matplotlib.pyplot.imshowmatplotlib.artist.Artist.set_clip_path