diff --git a/imucal/calibration_gui.py b/imucal/calibration_gui.py index 7ae4b4b..b17bbb2 100644 --- a/imucal/calibration_gui.py +++ b/imucal/calibration_gui.py @@ -26,6 +26,11 @@ class CalibrationGui: >>> labels["label2"] # First value is start, second value is end of region (500, 758) + Notes + ----- + If the toolbar is not visible at the bottom of the GUI, try reducing the `initial_figsize` parameter, when + creating the GUI. + """ section_list = None @@ -65,6 +70,7 @@ def __init__( expected_labels: Sequence[str], title: Optional[str] = None, master: Optional[tk.Frame] = None, + initial_figsize=(20, 10), ) -> None: """Launch new GUI instance. @@ -122,7 +128,7 @@ def __init__(self, canvas, window) -> None: self._create_sidebar() # Create a container - self.fig, self.axs = _create_figure(acc, gyro) + self.fig, self.axs = _create_figure(acc, gyro, figsize=initial_figsize) self.canvas = FigureCanvasTkAgg(self.fig, master=self.main_area) self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1) @@ -281,10 +287,10 @@ def _n_labels(self): return sum(all(v) for v in self.section_list.values()) -def _create_figure(acc, gyro): +def _create_figure(acc, gyro, figsize=(20, 10)): from matplotlib.figure import Figure - fig = Figure(figsize=(20, 10)) + fig = Figure(figsize=figsize) ax1 = fig.add_subplot(211) lines = ax1.plot(acc) ax1.grid(True) diff --git a/imucal/ferraris_calibration.py b/imucal/ferraris_calibration.py index 0038332..d5e3f0c 100644 --- a/imucal/ferraris_calibration.py +++ b/imucal/ferraris_calibration.py @@ -466,6 +466,7 @@ def ferraris_regions_from_interactive_plot( acc_cols: Iterable[str] = ("acc_x", "acc_y", "acc_z"), gyr_cols: Iterable[str] = ("gyr_x", "gyr_y", "gyr_z"), title: Optional[str] = None, + figsize=(20, 10), ) -> tuple[FerrarisSignalRegions, pd.DataFrame]: """Create a Calibration object by selecting the individual signal sections manually in an interactive GUI. @@ -497,6 +498,9 @@ def ferraris_regions_from_interactive_plot( The name of the 3 acceleration columns in order x,y,z. title : Optional title of the plot window + figsize : + The initial size of the plot window. + If you can not see the toolbar at the bottom, it might help to reduce the figure size. Returns ------- @@ -515,14 +519,16 @@ def ferraris_regions_from_interactive_plot( acc = data[list(acc_cols)].to_numpy() gyr = data[list(gyr_cols)].to_numpy() - section_list = _find_ferraris_regions_interactive(acc, gyr, title=title) + section_list = _find_ferraris_regions_interactive(acc, gyr, title=title, figsize=figsize) return ( ferraris_regions_from_section_list(data, section_list, gyr_cols=gyr_cols, acc_cols=acc_cols), section_list, ) -def _find_ferraris_regions_interactive(acc: np.ndarray, gyro: np.ndarray, title: Optional[str] = None): +def _find_ferraris_regions_interactive( + acc: np.ndarray, gyro: np.ndarray, title: Optional[str] = None, figsize=(20, 10) +): """Prepare the calibration data for the later calculation of calibration matrices. Parameters @@ -534,10 +540,11 @@ def _find_ferraris_regions_interactive(acc: np.ndarray, gyro: np.ndarray, title: title : Optional title for the Calibration GUI + """ from imucal.calibration_gui import CalibrationGui - plot = CalibrationGui(acc, gyro, FerrarisCalibration.FERRARIS_SECTIONS, title=title) + plot = CalibrationGui(acc, gyro, FerrarisCalibration.FERRARIS_SECTIONS, title=title, initial_figsize=figsize) section_list = plot.section_list