From 02fe64012c74cd7d0fb52d3bf967a698fee2e5d3 Mon Sep 17 00:00:00 2001 From: marques Date: Wed, 17 Dec 2025 15:33:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=98=E5=9B=BE=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E5=A2=9E=E5=BC=BAX=E8=BD=B4=E8=81=94?= =?UTF-8?q?=E5=8A=A8=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=B0=83=E6=95=B4=E5=88=BB?= =?UTF-8?q?=E5=BA=A6=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- func/Module_precisely_align.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/func/Module_precisely_align.py b/func/Module_precisely_align.py index 3ce01d5..cab4006 100644 --- a/func/Module_precisely_align.py +++ b/func/Module_precisely_align.py @@ -9,7 +9,7 @@ from PySide6.QtWidgets import QMessageBox, QMainWindow, QApplication, QButtonGro from matplotlib import gridspec, patches from matplotlib.backends.backend_qt import NavigationToolbar2QT from matplotlib.backends.backend_qtagg import FigureCanvasQTAgg -from matplotlib.ticker import FuncFormatter +from matplotlib.ticker import FuncFormatter, ScalarFormatter from numpy import (diff, where, correlate, corrcoef, searchsorted, sum as np_sum, max as np_max, min as np_min, arange, array, append, delete, abs as np_abs, argmin as np_argmin, argmax as np_argmax, asarray) @@ -477,21 +477,35 @@ class MainWindow_precisely_align(QMainWindow): else: return f"{int(x - self.data.approximately_align_pos)}" + + if sender == self.ui.pushButton_input: self.gs = gridspec.GridSpec(2, 1, height_ratios=[1, 1]) self.fig.subplots_adjust(top=0.95, bottom=0.05, right=0.98, left=0.05, hspace=0.15, wspace=0) self.ax0 = self.fig.add_subplot(self.gs[0]) self.ax0.grid(True) - self.ax0.xaxis.set_major_formatter(Params.FORMATTER) - self.ax1 = self.fig.add_subplot(self.gs[1], sharex=self.ax0, sharey=self.ax0) + # self.ax0.xaxis.set_major_formatter(Params.FORMATTER) + self.ax1 = self.fig.add_subplot(self.gs[1], sharey=self.ax0) self.ax1.grid(True) - self.ax1.xaxis.set_major_formatter(Params.FORMATTER) + # self.ax1.xaxis.set_major_formatter(Params.FORMATTER) Jpeak = self.data.Jpeak[:-2] Rpeak = self.data.Rpeak[:-2] self.ax0.set_title("JJIV") self.ax1.set_title("RRIV") + def on_xlim_changed(ax): + if ax is self.ax0: + x0, x1 = ax.get_xlim() + self.ax1.callbacks.disconnect('xlim_changed') + self.ax1.set_xlim(x0, x1) + self.ax1.callbacks.connect('xlim_changed', on_xlim_changed) + elif ax is self.ax1: + x0, x1 = ax.get_xlim() + self.ax0.callbacks.disconnect('xlim_changed') + self.ax0.set_xlim(x0, x1) + self.ax0.callbacks.connect('xlim_changed', on_xlim_changed) + if self.data.BCG_early: Jpeak = Jpeak - self.data.approximately_align_pos @@ -540,6 +554,12 @@ class MainWindow_precisely_align(QMainWindow): self.ax1.stem(Rpeak, plot_element["RRIVs"], markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE, label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV) + self.ax1.xaxis.set_major_formatter(Params.FORMATTER) + + self.ax0.callbacks.connect('xlim_changed', on_xlim_changed) + self.ax1.callbacks.connect('xlim_changed', on_xlim_changed) + + self.ax0.legend(loc=Constants.PLOT_UPPER_RIGHT) self.ax1.legend(loc=Constants.PLOT_UPPER_RIGHT) self.canvas.draw()