1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| from matplotlib.patches import PathPatch from matplotlib.path import Path
def getRect(points, color='blue',lw=1, flag=True, path=False): if flag: rec = np.array([[points[0], points[3]], [points[0], points[2]], [points[1], points[2]], [points[1], points[3]], [points[0], points[3]]]) else: rec = points pa = Path(rec) pathcopy = pa.copy() pa = pa.interpolated(100) patch = PathPatch(pa, facecolor='None', edgecolor=color, transform=ccrs.PlateCarree(), lw=lw) if path: return pathcopy else: return patch ax[i].add_patch(getRect([-180,-120,5,25])) ax[i].add_patch(getRect(np.array([[150,0],[210,0],[240,10],[240,40],[150,0]]), flag=False))
|