Python matplotlib.widgets.LassoSelector() Examples
The following are 8
code examples of matplotlib.widgets.LassoSelector().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.widgets
, or try the search function
.
Example #1
Source File: lasso_selector_demo_sgskip.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
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 = []
Example #2
Source File: segmentator_main.py From segmentator with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #3
Source File: test_widgets.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #4
Source File: SDS_classify.py From CoastSat with GNU General Public License v3.0 | 5 votes |
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)
Example #5
Source File: skeleton.py From DeepLabCut with GNU Lesser General Public License v3.0 | 5 votes |
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()
Example #6
Source File: tracklets.py From DeepLabCut with GNU Lesser General Public License v3.0 | 5 votes |
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()
Example #7
Source File: test_widgets.py From coffeegrindsize with MIT License | 5 votes |
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
Example #8
Source File: test_widgets.py From twitter-stock-recommendation with MIT License | 5 votes |
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