- 积分
- 62211
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2011-7-23
- 最后登录
- 1970-1-1
![未绑定新浪微博用户 新浪微博达人勋](source/plugin/sina_login/img/gray.png)
|
发表于 2023-4-27 21:42:56
|
显示全部楼层
设置一个clip_patch
下面是官网示例https://matplotlib.org/stable/ga ... -image-clip-path-py
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib.cbook as cbook
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() |
|