From cb9c89196fda0985b66ffc9499678efde8c830cc Mon Sep 17 00:00:00 2001 From: Andrew Sazonov Date: Wed, 23 Oct 2024 10:35:19 +0200 Subject: [PATCH] Fix sync of all X-axes on the analysis chart when zooming --- easydiffraction/Job.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/easydiffraction/Job.py b/easydiffraction/Job.py index 98287ad0..1d444a73 100644 --- a/easydiffraction/Job.py +++ b/easydiffraction/Job.py @@ -744,7 +744,7 @@ def show_analysis_chart(self): y_calc = self.calculate_profile() - peak_idx, _ = find_peaks(y_calc) #, prominence=1) + peak_idx, _ = find_peaks(y_calc) x_bragg = self.experiment.x.data[peak_idx] y_bragg = np.zeros_like(x_bragg) @@ -759,8 +759,8 @@ def show_analysis_chart(self): ) trace_bragg = go.Scatter( - x=x_bragg, # np.random.uniform(low=self.experiment.x.data.min(), high=self.experiment.x.data.max(), size=(50,)), - y=y_bragg, #np.zeros(50), + x=x_bragg, + y=y_bragg, xaxis='x2', yaxis='y2', line=dict(color='rgb(230, 171, 2)'), #color=px.colors.qualitative.Plotly[9]), @@ -778,7 +778,7 @@ def show_analysis_chart(self): y=self.background, xaxis='x3', yaxis='y3', - line=dict(color='gray'), # default: width=2? + line=dict(color='gray'), mode='lines', name='Background (Ibkg)' ) @@ -841,19 +841,18 @@ def show_analysis_chart(self): title_text=x_axis_title, anchor='y', range=[x_min, x_max], - # linecolor='blue', showline=True, mirror=True, zeroline=False ), xaxis2=dict( + matches='x', anchor='y2', range=[x_min, x_max], - # linecolor='green', showline=True, mirror=True, zeroline=False, showticklabels=False ), xaxis3=dict( + matches='x', anchor='y3', range=[x_min, x_max], - # linecolor='red', showline=True, mirror=True, zeroline=False, showticklabels=False ), yaxis=dict( @@ -861,7 +860,6 @@ def show_analysis_chart(self): domain=[0, resid_height / full_height - 0.01], range=[resid_y_min, resid_y_max], tickvals=[int(resid_y_min), 0, int(resid_y_max)], - # nticks = 3, showline=True, mirror=True, showgrid=False ), yaxis2=dict( @@ -877,10 +875,6 @@ def show_analysis_chart(self): ) fig = go.Figure(data=data, layout=layout) - - # fig.update_xaxes(showline=True, mirror=True) - # fig.update_yaxes(showline=True, mirror=True) - fig.show() def print_free_parameters(self):