本文整理汇总了Python中matplotlib.path.Path.reshape方法的典型用法代码示例。如果您正苦于以下问题:Python Path.reshape方法的具体用法?Python Path.reshape怎么用?Python Path.reshape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.path.Path
的用法示例。
在下文中一共展示了Path.reshape方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.path import Path [as 别名]
# 或者: from matplotlib.path.Path import reshape [as 别名]
def __init__(self, shape, scale=1):
"""
Initalize a Warper with a reference shape with coordinates in the
numpy array 'shape'
"""
xy = shape.copy() * scale
self.scale = scale
xy = self.shape_to_xy(xy)
xy = xy - np.min(xy,axis=0)
dt = scipy.spatial.Delaunay(xy)
# Define a grid
cols = int(np.ceil(np.max(xy[:,0])))
rows = int(np.ceil(np.max(xy[:,1])))
xx, yy = np.meshgrid(range(cols),range(rows))
xy_grid = np.vstack((xx.flatten(),yy.flatten())).T
# Define a mask
mask = Path(xy).contains_points(xy_grid)
self.mask = mask.reshape(xx.shape)
xy_grid = xy_grid[mask==True,:] # Remove pts not inside mask
# Calculate barycentric coordinates for all points inside mask
simplex_ids = dt.find_simplex(xy_grid)
bary_coords = points_to_bary(dt,simplex_ids,xy_grid)
self.tri = dt.simplices
self.warp_template = np.hstack((simplex_ids[:,np.newaxis],bary_coords))