From 917216b4251b6314ce677240694c0ed81a18971b Mon Sep 17 00:00:00 2001 From: abn Date: Tue, 15 Jan 2019 15:31:42 +0100 Subject: [PATCH] Bug fix : no auto fit if no curve and avoiding inf ranges --- tools/CurvePlot/src/python/views/XYView.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/CurvePlot/src/python/views/XYView.py b/tools/CurvePlot/src/python/views/XYView.py index 3c64d7d78..b4682ce71 100644 --- a/tools/CurvePlot/src/python/views/XYView.py +++ b/tools/CurvePlot/src/python/views/XYView.py @@ -270,12 +270,14 @@ class XYView(View): pass def autoFit(self, check=True, repaint=True): + import numpy as np if self.__repaintOK(): self._mplAxes.relim() xm, xM = self._mplAxes.xaxis.get_data_interval() ym, yM = self._mplAxes.yaxis.get_data_interval() i = yM-ym - self._mplAxes.axis([xm, xM, ym-i*self.AUTOFIT_MARGIN, yM+i*self.AUTOFIT_MARGIN]) + if np.isfinite(xm) and np.isfinite(xM) and np.isfinite(ym) and np.isfinite(yM): + self._mplAxes.axis([xm, xM, ym-i*self.AUTOFIT_MARGIN, yM+i*self.AUTOFIT_MARGIN]) if repaint: self.repaint() @@ -626,7 +628,8 @@ class XYView(View): self.changeFormatAxis() # Redo auto-fit - self.autoFit(repaint=False) + if len(self._curveViews): + self.autoFit(repaint=False) self.repaint() def onDataChange(self): -- 2.39.2