diff --git a/fsl/fslview/views/histogrampanel.py b/fsl/fslview/views/histogrampanel.py index 3168107f739430119a9dec6f571f3128271bc8ca..b4b700144d51aedbf34d83192cc949ade513b130 100644 --- a/fsl/fslview/views/histogrampanel.py +++ b/fsl/fslview/views/histogrampanel.py @@ -215,6 +215,12 @@ class HistogramSeries(plotpanel.DataSeries): log.debug('Calculating histogram for ' 'overlay {}'.format(self.overlay.name)) + if self.dataRange.xhi - self.dataRange.xlo < 0.00000001: + self.xdata = np.array([]) + self.ydata = np.array([]) + self.nvals = 0 + return + if self.ignoreZeros: if self.includeOutliers: data = self.nonZeroData else: data = self.clippedNonZeroData diff --git a/fsl/fslview/views/plotpanel.py b/fsl/fslview/views/plotpanel.py index a4b5ee46e2249c0bdea87f0f6789ac571c2fd410..f7da6140e151cbc8505dcdc9362007cf88163a8a 100644 --- a/fsl/fslview/views/plotpanel.py +++ b/fsl/fslview/views/plotpanel.py @@ -196,6 +196,13 @@ class PlotPanel(viewpanel.ViewPanel): (xmin, xmax), (ymin, ymax) = self.__calcLimits(xlims, ylims) + if xmax - xmin < 0.0000000001 or \ + ymax - ymin < 0.0000000001: + axis.clear() + canvas.draw() + self.Refresh() + return + # x/y axis labels xlabel = self.xlabel ylabel = self.ylabel @@ -269,6 +276,9 @@ class PlotPanel(viewpanel.ViewPanel): xdata, ydata = ds.getData() + if len(xdata) != len(ydata) or len(xdata) == 0: + return (0, 0), (0, 0) + # Note to self: If the smoothed data is # filled with NaNs, it is possibly due # to duplicate values in the x data, which @@ -290,6 +300,9 @@ class PlotPanel(viewpanel.ViewPanel): xdata[nans] = np.nan ydata[nans] = np.nan + if np.all(np.isnan(xdata) | np.isnan(ydata)): + return (0, 0), (0, 0) + kwargs = plotArgs kwargs['lw'] = kwargs.get('lw', ds.lineWidth) kwargs['alpha'] = kwargs.get('alpha', ds.alpha)