hyperspy.drawing._markers package¶
Submodules¶
hyperspy.drawing._markers.horizontal_line module¶
-
class
hyperspy.drawing._markers.horizontal_line.
HorizontalLine
(y, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Horizontal line marker that can be added to the signal figure
Parameters: - y (array or float) – The position of the line. 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.
- kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).
Example
>>> s = hs.signals.Signal1D(np.random.random([10, 100])) * 10 >>> m = hs.plot.markers.horizontal_line(y=range(10), color='green') >>> s.add_marker(m)
Adding a marker permanently to a signal >>> s = hs.signals.Signal1D(np.random.random([10, 100])) >>> m = hs.plot.markers.horizontal_line(y=5, color=’green’) >>> s.add_marker(m, permanent=True)
-
update
()¶
hyperspy.drawing._markers.horizontal_line_segment module¶
-
class
hyperspy.drawing._markers.horizontal_line_segment.
HorizontalLineSegment
(x1, x2, y, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Horizontal 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.
- x2 (array or float) – The position of the end of the line segment in x. see x1 arguments
- y (array or float) – The position of 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.horizontal_line_segment( >>> x1=20, x2=70, y=70, linewidth=4, color='red', linestyle='dotted') >>> im.add_marker(m)
Adding a marker permanently to a signal >>> im = hs.signals.Signal2D(np.zeros((100, 100))) >>> m = hs.plot.markers.horizontal_line_segment( >>> x1=10, x2=30, y=42, linewidth=4, color=’red’, linestyle=’dotted’) >>> im.add_marker(m, permanent=True)
-
update
()¶
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)
-
update
()¶
hyperspy.drawing._markers.point module¶
-
class
hyperspy.drawing._markers.point.
Point
(x, y, size=20, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Point marker that can be added to the signal figure.
If the signal has one or several navigation axes, the point marker can change as a function of the navigation position. This done by using an array for the x and y parameters. This array must have the same shape as the navigation axes of the signal.
Parameters: - x (array or float) – The position of the point 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.
- y (array or float) – The position of the point in y. see x arguments
- size (array or float, optional, default 20) – The size of the point. see x arguments
- kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).
Example
>>> im = hs.signals.Signal2D(np.random.random([10, 50, 50])) >>> m = hs.plot.markers.point(x=range(10), y=range(10)[::-1], color='red') >>> im.add_marker(m)
Adding a marker permanently to a signal >>> im = hs.signals.Signal2D(np.random.random([10, 50, 50])) >>> m = hs.plot.markers.point(10, 30, color=’blue’, size=50) >>> im.add_marker(m, permanent=True)
Markers on local maxima >>> from skimage.feature import peak_local_max >>> import scipy.misc >>> im = hs.signals.Signal2D(scipy.misc.ascent()).as_signal2D([2,0]) >>> index = array([peak_local_max(i.data, min_distance=100, num_peaks=4) >>> for i in im]) >>> for i in range(4): >>> m = hs.plot.markers.point(x=index[:, i, 1], >>> y=index[:, i, 0], color=’red’) >>> im.add_marker(m)
-
update
()¶
hyperspy.drawing._markers.rectangle module¶
-
class
hyperspy.drawing._markers.rectangle.
Rectangle
(x1, y1, x2, y2, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Rectangle marker that can be added to the signal figure
Parameters: - x1 (array or float) – The position of the up left corner of the rectangle 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 up left corner of the rectangle in y. see x1 arguments
- x2 (array or float) – The position of the down right corner of the rectangle in x. see x1 arguments
- y2 (array or float) – The position of the down right of the rectangle in y. see x1 arguments
- kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).
Example
>>> import scipy.misc >>> im = hs.signals.Signal2D(scipy.misc.ascent()) >>> m = hs.plot.markers.rectangle(x1=150, y1=100, x2=400, y2=400, >>> color='red') >>> im.add_marker(m)
Adding a marker permanently to a signal >>> im = hs.signals.Signal2D(np.random.random((50, 50)) >>> m = hs.plot.markers.rectangle(x1=20, y1=30, x2=40, y2=49) >>> im.add_marker(m, permanent=True)
-
update
()¶
hyperspy.drawing._markers.text module¶
-
class
hyperspy.drawing._markers.text.
Text
(x, y, text, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Text marker that can be added to the signal figure
Parameters: - x (array or float) – The position of the text 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.
- y (array or float) – The position of the text in y. see x arguments
- text (array or str) – The text. see x arguments
- kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).
Example
>>> s = hs.signals.Signal1D(np.arange(100).reshape([10,10])) >>> s.plot(navigator='spectrum') >>> for i in range(10): >>> m = hs.plot.markers.text(y=range(50,1000,100)[i], >>> x=i, text='abcdefghij'[i]) >>> s.add_marker(m, plot_on_signal=False) >>> m = hs.plot.markers.text(x=5, y=range(7,110, 10), >>> text=[i for i in 'abcdefghij']) >>> s.add_marker(m)
Add a marker permanently to a signal >>> s = hs.signals.Signal1D(np.arange(100).reshape([10,10])) >>> m = hs.plot.markers.text(5, 5, “a_text”) >>> s.add_marker(m, permanent=True)
-
update
()¶
hyperspy.drawing._markers.vertical_line module¶
-
class
hyperspy.drawing._markers.vertical_line.
VerticalLine
(x, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Vertical line marker that can be added to the signal figure
Parameters: - x (array or float) – The position of the line. 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.
- kwargs – Keywords argument of axvline valid properties (i.e. recognized by mpl.plot).
Example
>>> s = hs.signals.Signal1D(np.random.random([10, 100])) >>> m = hs.plot.markers.vertical_line(x=range(10), color='green') >>> s.add_marker(m)
Adding a marker permanently to a signal >>> s = hs.signals.Signal1D(np.random.random((100, 100))) >>> m = hs.plot.markers.vertical_line(x=30) >>> s.add_marker(m, permanent=True)
-
update
()¶
hyperspy.drawing._markers.vertical_line_segment module¶
-
class
hyperspy.drawing._markers.vertical_line_segment.
VerticalLineSegment
(x, y1, y2, **kwargs)¶ Bases:
hyperspy.drawing.marker.MarkerBase
Vertical line segment marker that can be added to the signal figure
Parameters: - x (array or float) – The position of 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 x. see x1 arguments
- y2 (array or float) – The position of the start 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.vertical_line_segment( >>> x=20, y1=30, y2=70, linewidth=4, color='red', linestyle='dotted') >>> im.add_marker(m)
Add a marker permanently to a marker >>> im = hs.signals.Signal2D(np.zeros((60, 60))) >>> m = hs.plot.markers.vertical_line_segment(x=10, y1=20, y2=50) >>> im.add_marker(m, permanent=True)
-
update
()¶