本文整理汇总了Python中matplotlib.widgets.CheckButtons.disconnect_events方法的典型用法代码示例。如果您正苦于以下问题:Python CheckButtons.disconnect_events方法的具体用法?Python CheckButtons.disconnect_events怎么用?Python CheckButtons.disconnect_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.widgets.CheckButtons
的用法示例。
在下文中一共展示了CheckButtons.disconnect_events方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AttributeSelector
# 需要导入模块: from matplotlib.widgets import CheckButtons [as 别名]
# 或者: from matplotlib.widgets.CheckButtons import disconnect_events [as 别名]
class AttributeSelector(object):
"""Select indices from a matplotlib collection using `LassoSelector`.
Selected indices are saved in the `ind` attribute. This tool highlights
selected points by fading them out (i.e., reducing their alpha values).
If your collection has alpha < 1, this tool will permanently alter them.
Note that this tool selects collection objects based on their *origins*
(i.e., `offsets`).
Parameters
----------
ax : :class:`~matplotlib.axes.Axes`
Axes to interact with.
collection : :class:`matplotlib.collections.Collection` subclass
Collection you want to select from.
alpha_other : 0 <= float <= 1
To highlight a selection, this tool sets all selected points to an
alpha value of 1 and non-selected points to `alpha_other`.
"""
def __init__(self, ax, collection, rax, raxmap, labels, labelcolors):
self.canvas = ax.figure.canvas
self.collection = collection
self.labelcolors = [colorConverter.to_rgba(c) for c in labelcolors]
self.labels = labels
self.xys = collection.get_offsets()
self.Npts = len(self.xys)
# Ensure that we have separate colors for each object
self.fc = collection.get_facecolors()
if len(self.fc) == 0:
raise ValueError('Collection must have a facecolor')
elif len(self.fc) == 1:
self.fc = np.tile(self.fc, self.Npts).reshape(self.Npts, -1)
self.sfc = self.fc.copy()
self.state = [False] * len(labels)
self.check = CheckButtons(rax,labels,self.state)
self.check.on_clicked(self.onclick)
self.raxmap = raxmap
self.ind = []
def updateselection(self, color):
if len(self.ind) > 0:
self.sfc[self.ind, :] = color
self.collection.set_facecolors(self.sfc)
self.canvas.draw_idle()
def onclick(self, label):
self.ind = raxmap[label]
labelindex = self.labels.index(label)
self.state[labelindex] = not self.state[labelindex]
if self.state[labelindex]:
color = self.labelcolors[labelindex]
else:
color = self.fc[self.ind,:]
self.updateselection(color)
def disconnect(self):
self.check.disconnect_events()
#self.fc[:, -1] = 1
self.collection.set_facecolors(self.fc)
self.canvas.draw_idle()