Skip to content

Commit 4eb0037

Browse files
authored
Merge pull request matplotlib#14285 from tacaswell/doc_spanselector_hardref
DOC: add note to example about keeping hard-ref to SpanSelector
2 parents 39192d5 + 2f9f301 commit 4eb0037

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

examples/widgets/span_selector.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ def onselect(xmin, xmax):
3838
ax2.set_ylim(thisy.min(), thisy.max())
3939
fig.canvas.draw()
4040

41-
# Set useblit=True on most backends for enhanced performance.
41+
#############################################################################
42+
# .. note
43+
#
44+
# If the SpanSelector object is garbage collected you will lose the
45+
# interactivity. You must keep a hard reference to it to prevent this.
46+
#
47+
48+
4249
span = SpanSelector(ax1, onselect, 'horizontal', useblit=True,
4350
rectprops=dict(alpha=0.5, facecolor='red'))
51+
# Set useblit=True on most backends for enhanced performance.
4452

4553

4654
plt.show()

0 commit comments

Comments
 (0)