本文整理汇总了Python中matplotlib.patches.PathPatch.set_visible方法的典型用法代码示例。如果您正苦于以下问题:Python PathPatch.set_visible方法的具体用法?Python PathPatch.set_visible怎么用?Python PathPatch.set_visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.patches.PathPatch
的用法示例。
在下文中一共展示了PathPatch.set_visible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MplPathROI
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_visible [as 别名]
class MplPathROI(MplPolygonalROI):
def roi_factory(self):
return Path()
def _setup_patch(self):
self._patch = None
def _sync_patch(self):
if self._patch is not None:
self._patch.remove()
self._patch = None
# Update geometry
if not self._roi.defined():
return
else:
x, y = self._roi.to_polygon()
p = MplPath(np.column_stack((x, y)))
self._patch = PathPatch(p)
self._patch.set_visible(True)
# Update appearance
self._patch.set(**self.plot_opts)
# Refresh
self._axes.figure.canvas.draw()
def finalize_selection(self, event):
self._mid_selection = False
if self._patch is not None:
self._patch.set_visible(False)
self._axes.figure.canvas.draw()
示例2: MplPathROI
# 需要导入模块: from matplotlib.patches import PathPatch [as 别名]
# 或者: from matplotlib.patches.PathPatch import set_visible [as 别名]
class MplPathROI(MplPolygonalROI):
"""
Matplotlib ROI for path selections
Parameters
----------
axes : `~matplotlib.axes.Axes`
The Matplotlib axes to draw to.
"""
_roi_cls = Path
def __init__(self, axes, roi=None):
super(MplPolygonalROI, self).__init__(axes)
self.plot_opts = {'edgecolor': PATCH_COLOR,
'facecolor': PATCH_COLOR,
'alpha': 0.3}
self._patch = None
def _sync_patch(self):
if self._patch is not None:
self._patch.remove()
self._patch = None
if self._roi.defined():
x, y = self._roi.to_polygon()
p = MplPath(np.column_stack((x, y)))
self._patch = PathPatch(p)
self._patch.set_visible(True)
self._patch.set(**self.plot_opts)
def finalize_selection(self, event):
self._mid_selection = False
if self._patch is not None:
self._patch.set_visible(False)
self._draw()