Closed effepivi closed 1 year ago
Hi,
A similar issue is reported in this thread [X].
So far, you can display static plots using inline snapshots [X].
%%capture __pip_output__
!pip install k3d
!pip install pyvista
import numpy as np
import k3d
from pyvista import examples
from IPython.display import HTML
You don't need to enable custom widgets
# from google.colab import output
# output.enable_custom_widget_manager()
# https://k3d-jupyter.org/gallery/showcase/terrain.html
dem = examples.download_crater_topo()
data = dem.get_array(0).reshape(dem.dimensions[::-1])[0, :, :].astype(np.float32)
plot = k3d.plot()
obj = k3d.surface(data,
attribute=data,
flat_shading=False,
color_map = k3d.colormaps.matplotlib_color_maps.viridis,
xmin=dem.bounds[0],
xmax=dem.bounds[1],
ymin=dem.bounds[2],
ymax=dem.bounds[3])
plot += obj
#plot.display()
plot.snapshot_type = 'inline'
HTML(plot.get_snapshot())
--or--
plot.snapshot_type = 'inline'
with open('output.html', 'w') as f:
f.write(plot.get_snapshot())
HTML(filename='output.html')
Thanks, it works!
Good news @effepivi , @Mr-McGL !
Experimental COLAB support is done: https://colab.research.google.com/drive/1aZd9vvPJBZzlX5bmaAIp8eE9f_0c3IaS?usp=sharing
@artur-trzesiok
Thanks for letting me know. I'll try it!
Thanks. It works!!!
Description
I am trying to use K3D on Google Colab. The viewer appears, I can interact with it (the grid moves) but the list of objects remains empty. I have tested using my own code, and also k3D examples. The issue always happens. See below for a screenshot and the corresponding code.
What I Did
I recycled one of K3D's examples:
Web console log / python logs
/usr/local/lib/python3.9/dist-packages/traittypes/traittypes.py:97: UserWarning: Given trait value dtype "int64" does not match required type "float32". A coerced copy has been created.