How to visualize a 3D array (kernel) with python (Google Colaboratory)?

95 Views Asked by At

I am trying to visualize a 3D kernel with Python, I used "mayavi" but i couldn't install "wxPython" in Google Colaboratory. Is there any other library that can help me?

kernel = np.array([[[0.88121283, 0.91759044, 0.5578005 ],
              [0.91488576, 0.9526534 , 0.5791151 ],
              [0.88121283, 0.91759044, 0.5578005 ]],

             [[0.88369477, 0.9201748 , 0.5593715 ],
              [0.91746247, 0.9553365 , 0.5807462 ],
              [0.88369477, 0.9201748 , 0.5593715 ]],

             [[0.88121283, 0.91759044, 0.5578005 ],
              [0.91488576, 0.9526534 , 0.5791151 ],
              [0.88121283, 0.91759044, 0.5578005 ]]])

This the code that I wrote

from mayavi import mlab
mlab.volume_slice(kernel, plane_orientation='x_axes', slice_index=3)
mlab.volume_slice(kernel, plane_orientation='y_axes', slice_index=3)
mlab.volume_slice(kernel, plane_orientation='z_axes', slice_index=3)
mlab.show()

mlab.contour3d(kernel)
mlab.show()

"mayavi" requires "wxPython" but i couldn't install. I tired pip install attrdict3 pip install requests pip install wxpython I got this error:

Building wheels for collected packages: wxpython
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for wxpython (setup.py) ... error
  ERROR: Failed building wheel for wxpython
  Running setup.py clean for wxpython
Failed to build wxpython
Installing collected packages: wxpython
  error: subprocess-exited-with-error
  
  × Running setup.py install for wxpython did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Running setup.py install for wxpython ... error
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> wxpython

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
0

There are 0 best solutions below