From ea63284737f0781041a53a46ff3d4b9da8c14ed3 Mon Sep 17 00:00:00 2001 From: Viljar Femoen Date: Thu, 13 Jun 2024 13:53:26 +0200 Subject: [PATCH] Add option for heatmap in plot_over_signal --- pyxem/signals/indexation_results.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pyxem/signals/indexation_results.py b/pyxem/signals/indexation_results.py index 06491c700..b854b70fe 100644 --- a/pyxem/signals/indexation_results.py +++ b/pyxem/signals/indexation_results.py @@ -768,8 +768,11 @@ def to_ipf_correlation_heatmap_markers( Notes ----- + It is recommended to have a large `n_keep` for this to look nice, e.g. 75% of the simulation bank. + This will not look good if the rotations used in the simulation(s) consists of multiple different regions in the IPF. + """ phase_idx_signal = hs.signals.Signal1D(self.to_phase_index()) phases = self.simulation.phases @@ -1140,9 +1143,9 @@ def plot_over_signal( signal, add_vector_markers=True, add_ipf_markers=True, + add_ipf_correlation_heatmap=False, add_ipf_colorkey=True, vector_kwargs=None, - ipf_marker_show_correlation=False, **kwargs, ): """Convenience method to plot the orientation map and the n-best matches over the signal. @@ -1155,6 +1158,9 @@ def plot_over_signal( If True, the vector markers will be added to the signal. add_ipf_markers : bool If True, the IPF best fit will be added to the signal in an overlay + add_ipf_correlation_heatmap : bool + If True, a correlation score heatmap as an IPF will be added to the signal in an overlay. + This overrides the `add_ipf_markers` parameter. add_ipf_colorkey : bool If True, the IPF colorkey will be added to the signal vector_kwargs : dict @@ -1173,10 +1179,12 @@ def plot_over_signal( signal.plot(navigator=nav, **kwargs) if add_vector_markers: signal.add_marker(self.to_markers(1, **vector_kwargs)) - if add_ipf_markers: - cmap = "magma" if ipf_marker_show_correlation else None - ipf_markers = self.to_ipf_markers(cmap=cmap) + if add_ipf_markers and not add_ipf_correlation_heatmap: + ipf_markers = self.to_ipf_markers() signal.add_marker(ipf_markers) + if add_ipf_correlation_heatmap: + heatmap_markers = self.to_ipf_correlation_heatmap_markers() + signal.add_marker(heatmap_markers) if add_ipf_colorkey: signal.add_marker( get_ipf_annotation_markers(self.simulation.phases), plot_on_signal=False