当前位置: 首页>>代码示例>>Python>>正文


Python collections.Collection方法代码示例

本文整理汇总了Python中matplotlib.collections.Collection方法的典型用法代码示例。如果您正苦于以下问题:Python collections.Collection方法的具体用法?Python collections.Collection怎么用?Python collections.Collection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.collections的用法示例。


在下文中一共展示了collections.Collection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check_visible

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import Collection [as 别名]
def _check_visible(self, collections, visible=True):
        """
        Check each artist is visible or not

        Parameters
        ----------
        collections : matplotlib Artist or its list-like
            target Artist or its list or collection
        visible : bool
            expected visibility
        """
        from matplotlib.collections import Collection
        if not isinstance(collections,
                          Collection) and not is_list_like(collections):
            collections = [collections]

        for patch in collections:
            assert patch.get_visible() == visible 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:common.py

示例2: _write_annotations

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import Collection [as 别名]
def _write_annotations(self, mesh: mpl_collections.Collection,
                           ax: plt.Axes) -> None:
        """Writes annotations to the center of cells. Internal."""
        for path, facecolor in zip(mesh.get_paths(), mesh.get_facecolors()):
            # Calculate the center of the cell, assuming that it is a square
            # centered at (x=col, y=row).
            vertices = path.vertices[:4]
            row = int(round(np.mean([v[1] for v in vertices])))
            col = int(round(np.mean([v[0] for v in vertices])))
            annotation = self.annot_map.get((row, col), '')
            if not annotation:
                continue
            face_luminance = relative_luminance(facecolor)
            text_color = 'black' if face_luminance > 0.4 else 'white'
            text_kwargs = dict(color=text_color, ha="center", va="center")
            text_kwargs.update(self.annot_kwargs)
            ax.text(col, row, annotation, **text_kwargs) 
开发者ID:quantumlib,项目名称:Cirq,代码行数:19,代码来源:heatmap.py


注:本文中的matplotlib.collections.Collection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。