From 8bed417b1da9839a7ca325ad85f20d9e11b1b09e Mon Sep 17 00:00:00 2001 From: Jash Shah <55907269+Jashshah6086@users.noreply.github.com> Date: Wed, 12 May 2021 18:02:04 +0530 Subject: [PATCH 1/2] Update span_selector.py --- examples/widgets/span_selector.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py index de446753382c..b51e4388f448 100644 --- a/examples/widgets/span_selector.py +++ b/examples/widgets/span_selector.py @@ -29,13 +29,15 @@ def onselect(xmin, xmax): indmin, indmax = np.searchsorted(x, (xmin, xmax)) indmax = min(len(x) - 1, indmax) - + region_x = x[indmin:indmax] region_y = y[indmin:indmax] - line2.set_data(region_x, region_y) - ax2.set_xlim(region_x[0], region_x[-1]) - ax2.set_ylim(region_y.min(), region_y.max()) - fig.canvas.draw() + + if len(region_x) >= 2: + line2.set_data(region_x, region_y) + ax2.set_xlim(region_x[0], region_x[-1]) + ax2.set_ylim(region_y.min(), region_y.max()) + fig.canvas.draw() ############################################################################# # .. note:: From 609a8402a4e51e272fd75d63a44e78ad55cc86a6 Mon Sep 17 00:00:00 2001 From: Jash Shah <55907269+Jashshah6086@users.noreply.github.com> Date: Thu, 13 May 2021 02:23:53 +0530 Subject: [PATCH 2/2] Update span_selector(Issue#20200) --- examples/widgets/span_selector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/widgets/span_selector.py b/examples/widgets/span_selector.py index b51e4388f448..8392be667cfd 100644 --- a/examples/widgets/span_selector.py +++ b/examples/widgets/span_selector.py @@ -29,10 +29,10 @@ def onselect(xmin, xmax): indmin, indmax = np.searchsorted(x, (xmin, xmax)) indmax = min(len(x) - 1, indmax) - + region_x = x[indmin:indmax] region_y = y[indmin:indmax] - + if len(region_x) >= 2: line2.set_data(region_x, region_y) ax2.set_xlim(region_x[0], region_x[-1])