Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Created October 4, 2019 23:25
Show Gist options
  • Save DataSolveProblems/780e5ad03cd0bd380f34644bf17ab12b to your computer and use it in GitHub Desktop.
Save DataSolveProblems/780e5ad03cd0bd380f34644bf17ab12b to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from matplotlib.widgets import SpanSelector
def onselect_function(min_value, max_value):
print(min_value, max_value)
return min_value, max_value
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [10, 50, 100])
span = SpanSelector(
ax,
onselect=onselect_function,
direction='vertical',
minspan=40,
useblit=True,
span_stays=True,
button=1,
rectprops={'facecolor': 'yellow', 'alpha': 0.3}
)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment