FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib/examples/api/span_regions.py at master · dpsanders/matplotlib · GitHub
dpsanders
matplotlib
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib
/
examples
/
api
/
span_regions.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (22 loc) · 791 Bytes
Breadcrumbs
matplotlib
/
examples
/
api
/
span_regions.py
Copy path
File metadata and controls
37 lines (22 loc) · 791 Bytes
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
"""
Illustrate some helper functions for shading regions where a logical
mask is True
See :meth:`matplotlib.collections.BrokenBarHCollection.span_where`
"""
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
import
matplotlib
.
collections
as
collections
t
=
np
.
arange
(
0.0
,
2
,
0.01
)
s1
=
np
.
sin
(
2
*
np
.
pi
*
t
)
s2
=
1.2
*
np
.
sin
(
4
*
np
.
pi
*
t
)
fig
,
ax
=
plt
.
subplots
()
ax
.
set_title
(
'using span_where'
)
ax
.
plot
(
t
,
s1
,
color
=
'black'
)
ax
.
axhline
(
0
,
color
=
'black'
,
lw
=
2
)
collection
=
collections
.
BrokenBarHCollection
.
span_where
(
t
,
ymin
=
0
,
ymax
=
1
,
where
=
s1
>
0
,
facecolor
=
'green'
,
alpha
=
0.5
)
ax
.
add_collection
(
collection
)
collection
=
collections
.
BrokenBarHCollection
.
span_where
(
t
,
ymin
=
-
1
,
ymax
=
0
,
where
=
s1
<
0
,
facecolor
=
'red'
,
alpha
=
0.5
)
ax
.
add_collection
(
collection
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL