8000 Update span_selector.py · matplotlib/matplotlib@8bed417 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8bed417

Browse files
authored
Update span_selector.py
1 parent b6a6414 commit 8bed417

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

examples/widgets/span_selector.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@
2929
def onselect(xmin, xmax):
3030
indmin, indmax = np.searchsorted(x, (xmin, xmax))
3131
indmax = min(len(x) - 1, indmax)
32-
32+
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