FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/mpl_examples/api/patch_collection.py at master · jkseppan/matplotlib.github.com · GitHub
jkseppan
/
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
/
patch_collection.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (44 loc) · 1.32 KB
Breadcrumbs
matplotlib.github.com
/
mpl_examples
/
api
/
patch_collection.py
Copy path
File metadata and controls
53 lines (44 loc) · 1.32 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
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
============================
Circles, Wedges and Polygons
============================
"""
import
numpy
as
np
import
matplotlib
from
matplotlib
.
patches
import
Circle
,
Wedge
,
Polygon
from
matplotlib
.
collections
import
PatchCollection
import
matplotlib
.
pyplot
as
plt
fig
,
ax
=
plt
.
subplots
()
resolution
=
50
# the number of vertices
N
=
3
x
=
np
.
random
.
rand
(
N
)
y
=
np
.
random
.
rand
(
N
)
radii
=
0.1
*
np
.
random
.
rand
(
N
)
patches
=
[]
for
x1
,
y1
,
r
in
zip
(
x
,
y
,
radii
):
circle
=
Circle
((
x1
,
y1
),
r
)
patches
.
append
(
circle
)
x
=
np
.
random
.
rand
(
N
)
y
=
np
.
random
.
rand
(
N
)
radii
=
0.1
*
np
.
random
.
rand
(
N
)
theta1
=
360.0
*
np
.
random
.
rand
(
N
)
theta2
=
360.0
*
np
.
random
.
rand
(
N
)
for
x1
,
y1
,
r
,
t1
,
t2
in
zip
(
x
,
y
,
radii
,
theta1
,
theta2
):
wedge
=
Wedge
((
x1
,
y1
),
r
,
t1
,
t2
)
patches
.
append
(
wedge
)
# Some limiting conditions on Wedge
patches
+=
[
Wedge
((
.3
,
.7
),
.1
,
0
,
360
),
# Full circle
Wedge
((
.7
,
.8
),
.2
,
0
,
360
,
width
=
0.05
),
# Full ring
Wedge
((
.8
,
.3
),
.2
,
0
,
45
),
# Full sector
Wedge
((
.8
,
.3
),
.2
,
45
,
90
,
width
=
0.10
),
# Ring sector
]
for
i
in
range
(
N
):
polygon
=
Polygon
(
np
.
random
.
rand
(
N
,
2
),
True
)
patches
.
append
(
polygon
)
colors
=
100
*
np
.
random
.
rand
(
len
(
patches
))
p
=
PatchCollection
(
patches
,
alpha
=
0.4
)
p
.
set_array
(
np
.
array
(
colors
))
ax
.
add_collection
(
p
)
fig
.
colorbar
(
p
,
ax
=
ax
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL