hyperspy.drawing._markers.line_segment module

class hyperspy.drawing._markers.line_segment.LineSegment(x1, y1, x2, y2, **kwargs)

Bases: hyperspy.drawing.marker.MarkerBase

Line segment marker that can be added to the signal figure

Parameters
  • x1 (array or float) – The position of the start of the line segment in x. If float, the marker is fixed. If array, the marker will be updated when navigating. The array should have the same dimensions in the navigation axes.

  • y1 (array or float) – The position of the start of the line segment in y. see x1 arguments

  • x2 (array or float) – The position of the end of the line segment in x. see x1 arguments

  • y2 (array or float) – The position of the end of the line segment in y. see x1 arguments

  • kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).

Example

>>> im = hs.signals.Signal2D(np.zeros((100, 100)))
>>> m = hs.plot.markers.line_segment(
>>>     x1=20, x2=70, y1=20, y2=70,
>>>     linewidth=4, color='red', linestyle='dotted')
>>> im.add_marker(m)

Permanently adding a marker to a signal

>>> im = hs.signals.Signal2D(np.zeros((100, 100)))
>>> m = hs.plot.markers.line_segment(
>>>     x1=10, x2=30, y1=50, y2=70,
>>>     linewidth=4, color='red', linestyle='dotted')
>>> im.add_marker(m, permanent=True)