Note
Go to the end to download the full example code.
Circle Markers#
Create a signal
import hyperspy.api as hs
import numpy as np
# Create a Signal2D with 1 navigation dimension
rng = np.random.default_rng(0)
data = np.ones((50, 100, 100))
s = hs.signals.Signal2D(data)
This first example shows how to draw static circles
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0.
warnings.warn(
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0.
warnings.warn(
Dynamic Circle Markers#
This second example shows how to draw dynamic circles whose position and radius change depending on the navigation position
s2 = hs.signals.Signal2D(data)
offsets = np.empty(s.axes_manager.navigation_shape, dtype=object)
sizes = np.empty(s.axes_manager.navigation_shape, dtype=object)
for ind in np.ndindex(offsets.shape):
offsets[ind] = rng.random((5, 2)) * 100
sizes[ind] = rng.random((5, )) * 10
m = hs.plot.markers.Circles(
sizes=sizes,
offsets=offsets,
edgecolor='r',
linewidth=5,
)
s2.plot()
s2.add_marker(m)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0.
warnings.warn(
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/site-packages/rsciio/utils/rgb_tools.py:62: VisibleDeprecationWarning: The module `rsciio.utils.rgb_tools` has been renamed to `rsciio.utils.rgb` and it will be removed in version 1.0.
warnings.warn(
sphinx_gallery_thumbnail_number = 4
Total running time of the script: (0 minutes 1.418 seconds)



