8000 Merge pull request #20212 from Jashshah6086/master · matplotlib/matplotlib@0554030 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0554030

Browse files
authored
Merge pull request #20212 from Jashshah6086/master
Update span_selector.py
2 parents e4154c4 + 609a840 commit 0554030

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

examples/widgets/span_selector.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ def onselect(xmin, xmax):
3232

3333
region_x = x[indmin:indmax]
3434
region_y = y[indmin:indmax]
35-
line2.set_data(region_x, region_y)
36-
ax2.set_xlim(region_x[0], region_x[-1])
37-
ax2.set_ylim(region_y.min(), region_y.max())
38-
fig.canvas.draw()
35+
36+
if len(region_x) >= 2:
37+
line2.set_data(region_x, region_y)
38+
ax2.set_xlim(region_x[0], region_x[-1])
39+
ax2.set_ylim(region_y.min(), region_y.max())
40+
fig.canvas.draw()
3941

4042
#############################################################################
4143
# .. note::

0 commit comments

Comments
 (0)
0