Sample data: Clear plots at redraw.

dev
Pierre-Antoine 2025-04-22 11:22:06 +02:00
parent 583da806e4
commit 334390abdb
1 changed files with 15 additions and 0 deletions

View File

@ -64,6 +64,7 @@ class SampleDataTab(QWidget):
super().__init__()
icon_folder = QIcon(os.path.join("icons", "folder.png"))
self._setup_attrs()
### --- General layout of widgets ---
@ -257,6 +258,11 @@ class SampleDataTab(QWidget):
self.combobox_PSD_plot.currentTextChanged.connect(self.plot_PSD_fine_and_sand_sediments)
def _setup_attrs(self):
self.figure_plot_sample_position_on_transect = None
self.figure_total_concentration = None
self.figure_plot_PSD = None
# -------------------- Functions for Sample Data Tab --------------------
def retranslate_data_sample_tab(self):
@ -789,6 +795,9 @@ class SampleDataTab(QWidget):
self.verticalLayout_groupbox_plot_transect\
.removeWidget(self.canvas_plot_sample_position_on_transect)
if self.figure_plot_sample_position_on_transect is not None:
self.figure_plot_sample_position_on_transect.clear()
fig, axis = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.figure_plot_sample_position_on_transect = fig
@ -1414,6 +1423,9 @@ class SampleDataTab(QWidget):
self.verticalLayout_groupbox_plot_total_concentration.removeWidget(self.canvas_plot_total_concentration)
self.verticalLayout_groupbox_plot_total_concentration.removeWidget(self.toolbar_plot_total_concentration)
if self.figure_total_concentration is not None:
self.figure_total_concentration.clear()
self.figure_total_concentration, self.axis_total_concentration \
= plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_plot_total_concentration = FigureCanvas(self.figure_total_concentration)
@ -1699,6 +1711,9 @@ class SampleDataTab(QWidget):
self.verticalLayout_groupbox_plot_PSD.removeWidget(self.canvas_plot_PSD)
self.verticalLayout_groupbox_plot_PSD.removeWidget(self.toolbar_plot_PSD)
if self.figure_plot_PSD is not None:
self.figure_plot_PSD.clear()
self.figure_plot_PSD, self.axis_plot_PSD \
= plt.subplots(nrows=1, ncols=2, layout="constrained")
self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD)