FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/mpl_examples/api/bbox_intersect.py at master · phobson/matplotlib.github.com · GitHub
phobson
/
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
/
mpl_examples
/
api
/
bbox_intersect.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (25 loc) · 891 Bytes
Breadcrumbs
matplotlib.github.com
/
mpl_examples
/
api
/
bbox_intersect.py
Copy path
File metadata and controls
33 lines (25 loc) · 891 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
33
"""
===========================================
Changing colors of lines intersecting a box
===========================================
The lines intersecting the rectangle are colored in red, while the others
are left as blue lines. This example showcases the `intersect_bbox` function.
"""
import
numpy
as
np
import
matplotlib
.
pyplot
as
plt
from
matplotlib
.
transforms
import
Bbox
from
matplotlib
.
path
import
Path
left
,
bottom
,
width
,
height
=
(
-
1
,
-
1
,
2
,
2
)
rect
=
plt
.
Rectangle
((
left
,
bottom
),
width
,
height
,
facecolor
=
"#aaaaaa"
)
fig
,
ax
=
plt
.
subplots
()
ax
.
add_patch
(
rect
)
bbox
=
Bbox
.
from_bounds
(
left
,
bottom
,
width
,
height
)
for
i
in
range
(
12
):
vertices
=
(
np
.
random
.
random
((
2
,
2
))
-
0.5
)
*
6.0
path
=
Path
(
vertices
)
if
path
.
intersects_bbox
(
bbox
):
color
=
'r'
else
:
color
=
'b'
ax
.
plot
(
vertices
[:,
0
],
vertices
[:,
1
],
color
=
color
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL