我认为你可以通过制作多个散点图来做到这一点,用一个独特的补丁剪裁每一个(例如一个有英格兰,一个有爱尔兰等)。尽管这可能不是您所要求的,即“有人知道我如何使用 'OR' 类型语句进行剪辑吗?”,它应该具有相同的效果:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
np.random.seed(101)
x = np.random.random(100)
y = np.random.random(100)
fig = plt.figure()
ax = fig.add_subplot(111)
imForEngland = ax.scatter(x,y)
fig.savefig('beforeclip.png')
imForWales = ax.scatter(x,y)
england = patches.Circle((.75,.75),radius=.25,fc='none')
wales = patches.Circle((.25,.25),radius=.25,fc='none')
ax.add_patch(england)
ax.add_patch(wales)
imForEngland.set_clip_path(england)
imForWales.set_clip_path(wales)
fig.savefig('afterclip.png')
补丁前:
补丁后:
