Background Window Plotting not working with 2D signal
k8macarthur opened this issue · 0 comments
k8macarthur commented
Describe the bug
Running the following line from the example note book:
cs.isig[5.:12.5].plot(True, integration_windows=iw, background_windows=bw)
Results in the following error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[15], line 1
----> 1 cs.isig[5.:12.5].plot(True, integration_windows=iw, background_windows=bw)
File ~\AppData\Local\anaconda3\lib\site-packages\exspy\signals\eds.py:933, in EDSSpectrum.plot(self, xray_lines, only_lines, only_one, background_windows, integration_windows, navigator, plot_markers, autoscale, norm, axes_manager, navigator_kwds, **kwargs)
857 """Plot the EDS spectrum. The following markers can be added
858
859 - The position of the X-ray lines and their names.
(...)
922 get_lines_intensity, estimate_background_windows
923 """
924 super().plot(
925 navigator=navigator,
926 plot_markers=plot_markers,
(...)
931 **kwargs,
932 )
--> 933 self._plot_xray_lines(
934 xray_lines,
935 only_lines,
936 only_one,
937 background_windows,
938 integration_windows,
939 render_figure=False,
940 )
941 self._render_figure(plot=["signal_plot"])
File ~\AppData\Local\anaconda3\lib\site-packages\exspy\signals\eds.py:989, in EDSSpectrum._plot_xray_lines(self, xray_lines, only_lines, only_one, background_windows, integration_windows, render_figure)
987 self.add_xray_lines_markers(xray_lines, render_figure=False)
988 if background_windows is not None:
--> 989 self._add_background_windows_markers(
990 background_windows, render_figure=False
991 )
992 if integration_windows is not None:
993 if integration_windows == "auto":
File ~\AppData\Local\anaconda3\lib\site-packages\exspy\signals\eds.py:1142, in EDSSpectrum._add_background_windows_markers(self, windows_position, render_figure)
1140 segments = np.array(segments)
1141 lines = hs.plot.markers.Lines(segments=segments, color="black")
-> 1142 self.add_marker(lines, render_figure=False)
1143 if render_figure:
1144 self._render_figure(plot=["signal_plot"])
File ~\AppData\Local\anaconda3\lib\site-packages\hyperspy\signal.py:6505, in BaseSignal.add_marker(self, marker, plot_on_signal, plot_marker, permanent, plot_signal, render_figure)
6502 raise ValueError("Markers can not be added to several signals")
6504 m._plot_on_signal = plot_on_signal
-> 6505 m._signal = self
6507 if plot_marker:
6508 if self._plot is None or not self._plot.is_active:
File ~\AppData\Local\anaconda3\lib\site-packages\hyperspy\drawing\markers.py:283, in Markers._signal(self, signal)
278 nav_shape = value.shape if is_iterating(value) else ()
279 if (
280 len(nav_shape) != 0
281 and nav_shape != signal.axes_manager.navigation_shape
282 ):
--> 283 raise ValueError(
284 "The shape of the variable length argument must match "
285 "the navigation shape of the signal."
286 )
287 self.__signal = signal
ValueError: The shape of the variable length argument must match the navigation shape of the signal.
Expected behavior
Should run without error and allow the user to navigate over pixels and see how the background fitting should be performing
Python environement:
- eXSpy version: 0.2
- HyperSpy version: 2.1.1
- Python version: 3.10.9