本文整理汇总了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
示例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)