Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 472072b

Browse files
committed
DOC: show off more keyword arguments in span selector demo
1 parent f10ab5c commit 472072b

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

examples/widgets/span_selector.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
fig, (ax1, ax2) = plt.subplots(2, figsize=(8, 6))
1717

1818
x = np.arange(0.0, 5.0, 0.01)
19-
y = np.sin(2*np.pi*x) + 0.5*np.random.randn(len(x))
19+
y = np.sin(2 * np.pi * x) + 0.5 * np.random.randn(len(x))
2020

2121
ax1.plot(x, y)
2222
ax1.set_ylim(-2, 2)
2323
ax1.set_title('Press left mouse button and drag '
2424
'to select a region in the top graph')
2525

26-
line2, = ax2.plot([], [])
26+
(line2,) = ax2.plot([], [])
2727

2828

2929
def onselect(xmin, xmax):
@@ -37,7 +37,8 @@ def onselect(xmin, xmax):
3737
line2.set_data(region_x, region_y)
3838
ax2.set_xlim(region_x[0], region_x[-1])
3939
ax2.set_ylim(region_y.min(), region_y.max())
40-
fig.canvas.draw()
40+
fig.canvas.draw_idle()
41+
4142

4243
#############################################################################
4344
# .. note::
@@ -47,8 +48,15 @@ def onselect(xmin, xmax):
4748
#
4849

4950

50-
span = SpanSelector(ax1, onselect, 'horizontal', useblit=True,
51-
rectprops=dict(alpha=0.5, facecolor='tab:blue'))
51+
span = SpanSelector(
52+
ax1,
53+
onselect,
54+
"horizontal",
55+
useblit=True,
56+
rectprops=dict(alpha=0.5, facecolor="tab:blue"),
57+
interactive=True,
58+
drag_from_anywhere=True
59+
)
5260
# Set useblit=True on most backends for enhanced performance.
5361

5462

0 commit comments

Comments
 (0)