From f0e4d00bbeb5104a29587ddb71fd8e00d9628b5f Mon Sep 17 00:00:00 2001 From: Lourens Veen Date: Fri, 1 Sep 2023 21:30:26 +0200 Subject: [PATCH] Fix error when we have too little data to have a cutoff --- muscle3/profiling.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/muscle3/profiling.py b/muscle3/profiling.py index cbf0d368..242dad97 100644 --- a/muscle3/profiling.py +++ b/muscle3/profiling.py @@ -297,18 +297,19 @@ def update_data(self, ax: Axes) -> None: for i in range(n_cur, n_avail): bars[i].set_visible(False) - # update cutoff bars - bars = self._bars['_CUTOFF'].patches - if cutoff: - for bar in bars: - bar.set_x(cutoff) - bar.set_width(self._global_xmax - cutoff) - bar.set_visible(True) - self._cutoff_warning.set_visible(True) - else: - for bar in bars: - bar.set_visible(False) - self._cutoff_warning.set_visible(False) + # update cutoff bars, if any + if '_CUTOFF' in self._bars: + bars = self._bars['_CUTOFF'].patches + if cutoff: + for bar in bars: + bar.set_x(cutoff) + bar.set_width(self._global_xmax - cutoff) + bar.set_visible(True) + self._cutoff_warning.set_visible(True) + else: + for bar in bars: + bar.set_visible(False) + self._cutoff_warning.set_visible(False) tplot = None # type: Optional[TimelinePlot]