hyperspy.drawing._markers.text module

class hyperspy.drawing._markers.text.Text(x, y, text, **kwargs)

Bases: 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 – Keyword arguments are passed to matplotlib.axes.Axes.text().

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)