Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
Problem
Trying to plot a volume inside a volume, with oneax.voxels
call, doesn't seem possible:
importmatplotlib.pyplotaspltimportnumpyasnpfrommatplotlibimportcolorsinner=np.zeros((4,4,4),dtype=bool)inner[1:3,1:3,1:3]=1outer=np.ones((4,4,4),dtype=bool)voxelarray=inner|outerfacecolors=np.empty(voxelarray.shape+ (4,),dtype=object)facecolors[outer]=colors.to_rgba("blue",alpha=0.5)facecolors[inner]=colors.to_rgba("red")fig=plt.figure()ax=fig.add_subplot(projection="3d")ax.voxels(voxelarray,facecolors=facecolors)fig.savefig("nested_volumes.png")
Nest volumes are possible if invokingax.voxels
twice:
outer_facecolors=np.empty(outer.shape+ (4,),dtype=object)outer_facecolors[outer]=colors.to_rgba("blue",alpha=0.5)inner_facecolors=np.empty(inner.shape,dtype=object)inner_facecolors[inner]="red"fig=plt.figure()ax=fig.add_subplot(projection="3d")ax.voxels(outer,facecolors=outer_facecolors)ax.voxels(inner,facecolors=inner_facecolors)ax.set_axis_off()plt.tight_layout()fig.savefig("nested_volumes.png",transparent=True)
Proposed solution
It would be nice ifmatplotlib
supportedalpha
withvoxels
for nested volumes.
Related:https://stackoverflow.com/questions/48672663/matplotlib-render-all-internal-voxels-with-alpha, which leads to the dupe#9745 that was closed due to inactivity