diff --git a/Orange/widgets/visualize/owscatterplotgraph.py b/Orange/widgets/visualize/owscatterplotgraph.py index 80bddde560f..db81a89df52 100644 --- a/Orange/widgets/visualize/owscatterplotgraph.py +++ b/Orange/widgets/visualize/owscatterplotgraph.py @@ -302,7 +302,10 @@ def tickValues(self, minVal, maxVal, size): step = int(np.ceil(float(len(ticks)) / max_steps)) ticks = ticks[::step] - spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:])) + # In case of a single tick, `default` will inform tickStrings + # about the appropriate scale. + spacing = min((b - a for a, b in zip(ticks[:-1], ticks[1:])), + default=maxVal - minVal) return [(spacing, ticks)] def tickStrings(self, values, scale, spacing): diff --git a/Orange/widgets/visualize/tests/test_owscatterplot.py b/Orange/widgets/visualize/tests/test_owscatterplot.py index 88802d6328c..51e2b39adb3 100644 --- a/Orange/widgets/visualize/tests/test_owscatterplot.py +++ b/Orange/widgets/visualize/tests/test_owscatterplot.py @@ -1130,6 +1130,10 @@ def test_time_axis(self): with self.assertRaises(ValueError): float(ticks[0]) + spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0] + self.assertEqual(spacing, 1582953776 - 1581953776) + self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776) + def test_clear_plot(self): self.widget.cb_class_density.setChecked(True) self.send_signal(self.widget.Inputs.data, self.data)