메모
전체 예제 코드를 다운로드 하려면 여기 를 클릭 하십시오.
3D 복셀/볼륨 플롯 #
를 사용하여 3D 체적 객체를 플로팅하는 방법을 보여줍니다 Axes3D.voxels
.
![복셀](/stable/_images/sphx_glr_voxels_001.png)
import matplotlib.pyplot as plt
import numpy as np
# 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
voxelarray = cube1 | cube2 | link
# set the colors of each object
colors = np.empty(voxelarray.shape, dtype=object)
colors[link] = 'red'
colors[cube1] = 'blue'
colors[cube2] = 'green'
# and plot everything
ax = plt.figure().add_subplot(projection='3d')
ax.voxels(voxelarray, facecolors=colors, edgecolor='k')
plt.show()