當前位置: 首頁>>代碼示例>>Python>>正文


Python path.get_path_collection_extents方法代碼示例

本文整理匯總了Python中matplotlib.path.get_path_collection_extents方法的典型用法代碼示例。如果您正苦於以下問題:Python path.get_path_collection_extents方法的具體用法?Python path.get_path_collection_extents怎麽用?Python path.get_path_collection_extents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.path的用法示例。


在下文中一共展示了path.get_path_collection_extents方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_datalim

# 需要導入模塊: from matplotlib import path [as 別名]
# 或者: from matplotlib.path import get_path_collection_extents [as 別名]
def get_datalim(self, transData):
        transform = self.get_transform()
        transOffset = self.get_offset_transform()
        offsets = self._offsets
        paths = self.get_paths()

        if not transform.is_affine:
            paths = [transform.transform_path_non_affine(p) for p in paths]
            transform = transform.get_affine()
        if not transOffset.is_affine:
            offsets = transOffset.transform_non_affine(offsets)
            transOffset = transOffset.get_affine()

        offsets = np.asanyarray(offsets, np.float_)
        if np.ma.isMaskedArray(offsets):
            offsets = offsets.filled(np.nan)
            # get_path_collection_extents handles nan but not masked arrays
        offsets.shape = (-1, 2)                     # Make it Nx2

        if paths:
            result = mpath.get_path_collection_extents(
                transform.frozen(), paths, self.get_transforms(),
                offsets, transOffset.frozen())
            result = result.inverse_transformed(transData)
        else:
            result = transforms.Bbox([[0, 0], [0, 0]])
        return result 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:29,代碼來源:collections.py

示例2: get_datalim

# 需要導入模塊: from matplotlib import path [as 別名]
# 或者: from matplotlib.path import get_path_collection_extents [as 別名]
def get_datalim(self, transData):
        transform = self.get_transform()
        transOffset = self.get_offset_transform()
        offsets = self._offsets
        paths = self.get_paths()

        if not transform.is_affine:
            paths = [transform.transform_path_non_affine(p) for p in paths]
            transform = transform.get_affine()
        if not transOffset.is_affine:
            offsets = transOffset.transform_non_affine(offsets)
            transOffset = transOffset.get_affine()

        offsets = np.asanyarray(offsets, np.float_)
        if np.ma.isMaskedArray(offsets):
            offsets = offsets.filled(np.nan)
            # get_path_collection_extents handles nan but not masked arrays
        offsets.shape = (-1, 2)                     # Make it Nx2

        if len(paths) and len(offsets):
            result = mpath.get_path_collection_extents(
                transform.frozen(), paths, self.get_transforms(),
                offsets, transOffset.frozen())
            result = result.inverse_transformed(transData)
        else:
            result = transforms.Bbox.null()
        return result 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:29,代碼來源:collections.py

示例3: getbb

# 需要導入模塊: from matplotlib import path [as 別名]
# 或者: from matplotlib.path import get_path_collection_extents [as 別名]
def getbb(sc, ax):
    """
    Function to return a list of bounding boxes in data coordinates for a scatter plot.
    Directly taken from https://stackoverflow.com/questions/55005272/
    """
    ax.figure.canvas.draw()  # need to draw before the transforms are set.
    transform = sc.get_transform()
    transOffset = sc.get_offset_transform()
    offsets = sc._offsets
    paths = sc.get_paths()
    transforms = sc.get_transforms()

    if not transform.is_affine:
        paths = [transform.transform_path_non_affine(p) for p in paths]
        transform = transform.get_affine()
    if not transOffset.is_affine:
        offsets = transOffset.transform_non_affine(offsets)
        transOffset = transOffset.get_affine()

    if isinstance(offsets, np.ma.MaskedArray):
        offsets = offsets.filled(np.nan)

    bboxes = []

    if len(paths) and len(offsets):
        if len(paths) < len(offsets):
            # for usual scatters you have one path, but several offsets
            paths = [paths[0]] * len(offsets)
        if len(transforms) < len(offsets):
            # often you may have a single scatter size, but several offsets
            transforms = [transforms[0]] * len(offsets)

        for p, o, t in zip(paths, offsets, transforms):
            result = get_path_collection_extents(
                transform.frozen(), [p], [t], [o], transOffset.frozen()
            )
            bboxes.append(result.inverse_transformed(ax.transData))

    return bboxes 
開發者ID:theislab,項目名稱:scvelo,代碼行數:41,代碼來源:paga.py


注:本文中的matplotlib.path.get_path_collection_extents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。