Want to scale the voxel-dimensions with Matplotlib. How can I do this?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
voxels accept the coordinates of the grid onto which to place the voxels.
voxels([x, y, z, ]/, filled, ...)
x, y, z
: 3D np.array, optional
The coordinates of the corners of the voxels. This should broadcast to a shape one larger in every dimension than the shape of filled. These can be used to plot non-cubic voxels.If not specified, defaults to increasing integers along each axis, like those returned by indices(). As indicated by the / in the function signature, these arguments can only be passed positionally.
In this case,
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.gca(projection='3d')
# Make grid
voxels = np.zeros((6, 6, 6))
# Activate single Voxel
voxels[1, 0, 4] = True
x,y,z = np.indices(np.array(voxels.shape)+1)
ax.voxels(x*0.5, y, z, voxels, edgecolor="k")
ax.set_xlabel('0 - Dim')
ax.set_ylabel('1 - Dim')
ax.set_zlabel('2 - Dim')
plt.show()