Skip to content
Snippets Groups Projects
Commit 3b60dc74 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Added a bunch of edge-cases for bad plot data

parent ac573ec4
No related branches found
No related tags found
No related merge requests found
...@@ -215,6 +215,12 @@ class HistogramSeries(plotpanel.DataSeries): ...@@ -215,6 +215,12 @@ class HistogramSeries(plotpanel.DataSeries):
log.debug('Calculating histogram for ' log.debug('Calculating histogram for '
'overlay {}'.format(self.overlay.name)) '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.ignoreZeros:
if self.includeOutliers: data = self.nonZeroData if self.includeOutliers: data = self.nonZeroData
else: data = self.clippedNonZeroData else: data = self.clippedNonZeroData
......
...@@ -196,6 +196,13 @@ class PlotPanel(viewpanel.ViewPanel): ...@@ -196,6 +196,13 @@ class PlotPanel(viewpanel.ViewPanel):
(xmin, xmax), (ymin, ymax) = self.__calcLimits(xlims, ylims) (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 # x/y axis labels
xlabel = self.xlabel xlabel = self.xlabel
ylabel = self.ylabel ylabel = self.ylabel
...@@ -269,6 +276,9 @@ class PlotPanel(viewpanel.ViewPanel): ...@@ -269,6 +276,9 @@ class PlotPanel(viewpanel.ViewPanel):
xdata, ydata = ds.getData() 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 # Note to self: If the smoothed data is
# filled with NaNs, it is possibly due # filled with NaNs, it is possibly due
# to duplicate values in the x data, which # to duplicate values in the x data, which
...@@ -290,6 +300,9 @@ class PlotPanel(viewpanel.ViewPanel): ...@@ -290,6 +300,9 @@ class PlotPanel(viewpanel.ViewPanel):
xdata[nans] = np.nan xdata[nans] = np.nan
ydata[nans] = np.nan ydata[nans] = np.nan
if np.all(np.isnan(xdata) | np.isnan(ydata)):
return (0, 0), (0, 0)
kwargs = plotArgs kwargs = plotArgs
kwargs['lw'] = kwargs.get('lw', ds.lineWidth) kwargs['lw'] = kwargs.get('lw', ds.lineWidth)
kwargs['alpha'] = kwargs.get('alpha', ds.alpha) kwargs['alpha'] = kwargs.get('alpha', ds.alpha)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment