Python matplotlib.widgets.SpanSelector() Examples
The following are 5
code examples of matplotlib.widgets.SpanSelector().
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: view.py From ms_deisotope with Apache License 2.0 | 6 votes |
def configure_canvas(self): self.figure = Figure(dpi=100) self.canvas = FigureCanvasTkAgg(self.figure, master=self) self.axis = self.figure.add_subplot(111) self.canvas.draw() canvas_widget = self.canvas.get_tk_widget() canvas_widget.grid(row=0, column=0, sticky=tk.N + tk.W + tk.E + tk.S) self.canvas_cursor = Cursor(self.axis, tk.StringVar(master=self.root)) self.canvas.mpl_connect('motion_notify_event', self.canvas_cursor.mouse_move) self.span = SpanSelector( self.axis, self.zoom, 'horizontal', useblit=True, rectprops=dict(alpha=0.5, facecolor='red')) self.mz_span = None self.scan = None self.annotations = [] self.canvas.draw()
Example #2
Source File: test_widgets.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def check_span(*args, **kwargs): ax = get_ax() def onselect(vmin, vmax): ax._got_onselect = True assert vmin == 100 assert vmax == 150 def onmove(vmin, vmax): assert vmin == 100 assert vmax == 125 ax._got_on_move = True if 'onmove_callback' in kwargs: kwargs['onmove_callback'] = onmove tool = widgets.SpanSelector(ax, onselect, *args, **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 if 'onmove_callback' in kwargs: assert ax._got_on_move
Example #3
Source File: filter.py From picasso with MIT License | 6 votes |
def plot(self): # Prepare the data data = self.locs[self.field] data = data[np.isfinite(data)] bins = lib.calculate_optimal_bins(data, 1000) # Prepare the figure self.figure.clear() self.figure.suptitle(self.field) axes = self.figure.add_subplot(111) axes.hist(data, bins, rwidth=1, linewidth=0) data_range = data.ptp() axes.set_xlim( [bins[0] - 0.05 * data_range, data.max() + 0.05 * data_range] ) self.span = SpanSelector( axes, self.on_span_select, "horizontal", useblit=True, rectprops=dict(facecolor="green", alpha=0.2), ) self.canvas.draw()
Example #4
Source File: test_widgets.py From coffeegrindsize with MIT License | 6 votes |
def check_span(*args, **kwargs): ax = get_ax() def onselect(vmin, vmax): ax._got_onselect = True assert vmin == 100 assert vmax == 150 def onmove(vmin, vmax): assert vmin == 100 assert vmax == 125 ax._got_on_move = True if 'onmove_callback' in kwargs: kwargs['onmove_callback'] = onmove tool = widgets.SpanSelector(ax, onselect, *args, **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 if 'onmove_callback' in kwargs: assert ax._got_on_move
Example #5
Source File: test_widgets.py From twitter-stock-recommendation with MIT License | 6 votes |
def check_span(*args, **kwargs): ax = get_ax() def onselect(vmin, vmax): ax._got_onselect = True assert vmin == 100 assert vmax == 150 def onmove(vmin, vmax): assert vmin == 100 assert vmax == 125 ax._got_on_move = True if 'onmove_callback' in kwargs: kwargs['onmove_callback'] = onmove tool = widgets.SpanSelector(ax, onselect, *args, **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 if 'onmove_callback' in kwargs: assert ax._got_on_move