FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
matplotlib.github.com/2.2.0/gallery/mplot3d/voxels.py at main · matplotlib/matplotlib.github.com · GitHub
matplotlib
/
matplotlib.github.com
Public
Notifications
You must be signed in to change notification settings
Fork
62
Star
29
Code
Issues
1
Pull requests
2
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
matplotlib.github.com
/
2.2.0
/
gallery
/
mplot3d
/
voxels.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (27 loc) · 875 Bytes
Breadcrumbs
matplotlib.github.com
/
2.2.0
/
gallery
/
mplot3d
/
voxels.py
Copy path
File metadata and controls
35 lines (27 loc) · 875 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
34
35
'''
==========================
3D voxel / volumetric plot
==========================
Demonstrates plotting 3D volumetric objects with ``ax.voxels``
'''
import
matplotlib
.
pyplot
as
plt
import
numpy
as
np
from
mpl_toolkits
.
mplot3d
import
Axes3D
# prepare some coordinates
x
,
y
,
z
=
np
.
indices
((
8
,
8
,
8
))
# draw cuboids in the top left and bottom right corners, and a link between them
cube1
=
(
x
<
3
)
&
(
y
<
3
)
&
(
z
<
3
)
cube2
=
(
x
>=
5
)
&
(
y
>=
5
)
&
(
z
>=
5
)
link
=
abs
(
x
-
y
)
+
abs
(
y
-
z
)
+
abs
(
z
-
x
)
<=
2
# combine the objects into a single boolean array
voxels
=
cube1
|
cube2
|
link
# set the colors of each object
colors
=
np
.
empty
(
voxels
.
shape
,
dtype
=
object
)
colors
[
link
]
=
'red'
colors
[
cube1
]
=
'blue'
colors
[
cube2
]
=
'green'
# and plot everything
fig
=
plt
.
figure
()
ax
=
fig
.
gca
(
projection
=
'3d'
)
ax
.
voxels
(
voxels
,
facecolors
=
colors
,
edgecolor
=
'k'
)
plt
.
show
()
Back
|
FazBrowse Home
|
New Git URL