用补丁裁剪图像#

被圆形补丁裁剪的图像演示。

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()
image clip path

参考资料

本示例展示了以下函数、方法、类和模块的使用

由 Sphinx-Gallery 生成的图库