本文整理汇总了Python中matplotlib.widgets.LassoSelector方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.LassoSelector方法的具体用法?Python widgets.LassoSelector怎么用?Python widgets.LassoSelector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.widgets
的用法示例。
在下文中一共展示了widgets.LassoSelector方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def __init__(self, ax, collection, alpha_other=0.3):
self.canvas = ax.figure.canvas
self.collection = collection
self.alpha_other = alpha_other
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, 1))
self.lasso = LassoSelector(ax, onselect=self.onselect)
self.ind = []
示例2: lassoSwitch
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def lassoSwitch(event):
"""Enable disable lasso tool."""
global lasso
lasso = []
flexFig.lassoSwitchCount = (flexFig.lassoSwitchCount+1) % 2
if flexFig.lassoSwitchCount == 1: # enable lasso
flexFig.disconnect() # disable drag function of sector mask
lasso = LassoSelector(ax, onselect)
bLasso.label.set_text("Lasso\nOn")
# Make erase button appear on in lasso mode
bLassoErase.ax.patch.set_visible(True)
bLassoErase.label.set_visible(True)
bLassoErase.ax.axis('on')
else: # disable lasso
flexFig.connect() # enable drag function of sector mask
bLasso.label.set_text("Lasso\nOff")
# Make erase button disappear
bLassoErase.ax.patch.set_visible(False)
bLassoErase.label.set_visible(False)
bLassoErase.ax.axis('off')
# Pixel coordinates
示例3: check_lasso_selector
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def check_lasso_selector(**kwargs):
ax = get_ax()
def onselect(verts):
ax._got_onselect = True
assert verts == [(100, 100), (125, 125), (150, 150)]
tool = widgets.LassoSelector(ax, onselect, **kwargs)
do_event(tool, 'press', xdata=100, ydata=100, button=1)
do_event(tool, 'onmove', xdata=125, ydata=125, button=1)
do_event(tool, 'release', xdata=150, ydata=150, button=1)
assert ax._got_onselect
示例4: __init__
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def __init__(self, ax, implot, color=[1,1,1]):
self.canvas = ax.figure.canvas
self.implot = implot
self.array = implot.get_array()
xv, yv = np.meshgrid(np.arange(self.array.shape[1]),np.arange(self.array.shape[0]))
self.pix = np.vstack( (xv.flatten(), yv.flatten()) ).T
self.ind = []
self.im_bool = np.zeros((self.array.shape[0], self.array.shape[1]))
self.color = color
self.lasso = LassoSelector(ax, onselect=self.onselect)
示例5: show
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def show(self):
self.fig = plt.figure()
ax = self.fig.add_subplot(111)
ax.axis("off")
lo = np.nanmin(self.xy, axis=0)
hi = np.nanmax(self.xy, axis=0)
center = (hi + lo) / 2
w, h = hi - lo
ampl = 1.3
w *= ampl
h *= ampl
ax.set_xlim(center[0] - w / 2, center[0] + w / 2)
ax.set_ylim(center[1] - h / 2, center[1] + h / 2)
ax.imshow(self.image)
ax.scatter(*self.xy.T, s=self.cfg["dotsize"] ** 2)
ax.add_collection(self.lines)
ax.invert_yaxis()
self.lasso = LassoSelector(ax, onselect=self.on_select)
ax_clear = self.fig.add_axes([0.85, 0.55, 0.1, 0.1])
ax_export = self.fig.add_axes([0.85, 0.45, 0.1, 0.1])
self.clear_button = Button(ax_clear, "Clear")
self.clear_button.on_clicked(self.clear)
self.export_button = Button(ax_export, "Export")
self.export_button.on_clicked(self.export)
self.fig.canvas.mpl_connect("pick_event", self.on_pick)
plt.show()
示例6: __init__
# 需要导入模块: from matplotlib import widgets [as 别名]
# 或者: from matplotlib.widgets import LassoSelector [as 别名]
def __init__(self, tracker, ax, collection, alpha, alpha_other=0.2):
self.tracker = tracker
self.ax = ax
self.collection = collection
self.fc = collection.get_facecolors()
self.alpha = alpha
self.alpha_other = alpha_other
self.lasso = LassoSelector(ax, onselect=self.on_select)
self.is_connected = True
self.toggle()