hyperspy.drawing._widgets.range module

class hyperspy.drawing._widgets.range.ModifiableSpanSelector(ax, **kwargs)

Bases: matplotlib.widgets.SpanSelector

draw_patch(*args)

Update the patch drawing.

release(event)

When the button is released, the span stays in the screen and the iteractivity machinery passes to modify mode

set_initial(initial_range=None)

Remove selection events, set the spanner, and go to modify mode.

update(*args)

Draw using blit() or draw_idle(), depending on self.useblit.

class hyperspy.drawing._widgets.range.RangeWidget(axes_manager, ax=None, alpha=0.5, **kwargs)

Bases: hyperspy.drawing.widget.ResizableDraggableWidgetBase

RangeWidget is a span-patch based widget, which can be dragged and resized by mouse/keys. Basically a wrapper for ModifiablepanSelector so that it conforms to the common widget interface.

For optimized changes of geometry, the class implements two methods ‘set_bounds’ and ‘set_ibounds’, to set the geometry of the rectangle by value and index space coordinates, respectivly.

Implements the internal method _validate_geometry to make sure the patch will always stay within bounds.

_add_patch_to(ax)

Create and add the matplotlib patches to ‘ax’

_update_patch_geometry()

Updates all geometry of the patch on the plot.

_update_patch_position()

Updates the position of the patch on the plot.

_update_patch_size()

Updates the size of the patch on the plot.

_validate_geometry(x1=None)

Make sure the entire patch always stays within bounds. First the position (either from position property or from x1 argument), is limited within the bounds. Then, if the right edge are out of bounds, the position is changed so that they will be at the limit.

The modified geometry is stored, but no change checks are performed. Call _apply_changes after this in order to process any changes (the size might change if it is set larger than the bounds size).

disconnect()

Disconnect from all events (both matplotlib and navigation).

set_bounds(*args, **kwargs)

Set bounds by values. Bounds can either be specified in order left, bottom, width, height; or by keywords:

  • ‘bounds’: tuple (left, width)

OR

  • ‘x’/’left’

  • ‘w’/’width’, alternatively ‘right’ (x+w)

If specifying with keywords, any unspecified dimensions will be kept constant (note: width will be kept, not right).

set_ibounds(*args, **kwargs)

Set bounds by indices. Bounds can either be specified in order left, bottom, width, height; or by keywords:

  • ‘bounds’: tuple (left, width)

OR

  • ‘x’/’left’

  • ‘w’/’width’, alternatively ‘right’

If specifying with keywords, any unspecified dimensions will be kept constant (note: width will be kept, not right).

set_on(value, render_figure=True)

Change the on state of the widget. If turning off, all patches will be removed from the matplotlib axes and the widget will disconnect from all events. If turning on, the patch(es) will be added to the matplotlib axes, and the widget will connect to its default events.