3D plotting with X3DOM in docker container

Hi,
I want use X3DOM.html() for plotting. I’m running FEniCs in a docker container on a MAC. It works fine for the mesh but it throws an error for the solution u:

from dolfin import *
from IPython.display import HTML

mesh = BoxMesh(Point(0.0, 0.0, 0.0), Point(10., 4., 2.), 5, 5, 5)
V = FunctionSpace(mesh, "Lagrange", 1)
u = interpolate(Constant(1.0), V)

plot(u) # works fine
HTML(X3DOM.html(mesh)) # works fine
HTML(X3DOM.html(u)) # throws error

Error message:

I’m not familiar with X3DOM.html(), but, based on the types listed in the error message, you can try

HTML(X3DOM.html(u.cpp_object()))

To see why this makes sense, check

print(type(u))
print(type(u.cpp_object()))
1 Like