FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/examples/widgets/span_selector.py at master · Redwa/matplotlib.github.com · GitHub
Redwa
/
matplotlib.github.com
Public
forked from
matplotlib/matplotlib.github.com
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
examples
/
widgets
/
span_selector.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (30 loc) · 1.07 KB
Breadcrumbs
matplotlib.github.com
/
examples
/
widgets
/
span_selector.py
Copy path
File metadata and controls
40 lines (30 loc) · 1.07 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
"""
The SpanSelector is a mouse widget to select a xmin/xmax range and plot the
detail view of the selected region in the lower axes
"""
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
from
matplotlib
.
widgets
import
SpanSelector
fig
=
plt
.
figure
(
figsize
=
(
8
,
6
))
ax
=
fig
.
add_subplot
(
211
,
axisbg
=
'#FFFFCC'
)
x
=
np
.
arange
(
0.0
,
5.0
,
0.01
)
y
=
np
.
sin
(
2
*
np
.
pi
*
x
)
+
0.5
*
np
.
random
.
randn
(
len
(
x
))
ax
.
plot
(
x
,
y
,
'-'
)
ax
.
set_ylim
(
-
2
,
2
)
ax
.
set_title
(
'Press left mouse button and drag to test'
)
ax2
=
fig
.
add_subplot
(
212
,
axisbg
=
'#FFFFCC'
)
line2
,
=
ax2
.
plot
(
x
,
y
,
'-'
)
def
onselect
(
xmin
,
xmax
):
indmin
,
indmax
=
np
.
searchsorted
(
x
, (
xmin
,
xmax
))
indmax
=
min
(
len
(
x
)
-
1
,
indmax
)
thisx
=
x
[
indmin
:
indmax
]
thisy
=
y
[
indmin
:
indmax
]
line2
.
set_data
(
thisx
,
thisy
)
ax2
.
set_xlim
(
thisx
[
0
],
thisx
[
-
1
])
ax2
.
set_ylim
(
thisy
.
min
(),
thisy
.
max
())
fig
.
canvas
.
draw
()
# set useblit True on gtkagg for enhanced performance
span
=
SpanSelector
(
ax
,
onselect
,
'horizontal'
,
useblit
=
True
,
rectprops
=
dict
(
alpha
=
0.5
,
facecolor
=
'red'
))
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL