新增偏移格式化函数,优化BCG提前模式下的X轴刻度显示

This commit is contained in:
2025-12-17 15:00:05 +08:00
parent ea024eafbc
commit 6845626fe9

View File

@ -9,6 +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 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)
@ -470,6 +471,12 @@ class MainWindow_precisely_align(QMainWindow):
sender = self.sender()
def offset_formatter(x, pos):
if self.data.BCG_early:
return f"{int(x + self.data.approximately_align_pos)}"
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)
@ -528,6 +535,8 @@ class MainWindow_precisely_align(QMainWindow):
self.ax0.stem(Jpeak, plot_element["JJIVs"],
markerfmt="C0.", linefmt=Constants.PLOT_COLOR_GREEN,
label=Constants.PRECISELY_ALIGN_PLOT_LABEL_JJIV)
self.ax0.xaxis.set_major_formatter(FuncFormatter(offset_formatter))
self.ax1.stem(Rpeak, plot_element["RRIVs"],
markerfmt="C0.", linefmt=Constants.PLOT_COLOR_ORANGE,
label=Constants.PRECISELY_ALIGN_PLOT_LABEL_RRIV)