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)
_plot_marker()
update()