This example demonstrates:

  • using DG0 Function
  • setting a colormap from matplotlib
  • manifold mesh

In [1]:
from dolfin import *
import numpy.linalg

mesh = SphericalShellMesh(mpi_comm_world(), 1)
for i in range(3):
    mesh = refine(mesh)
for x in mesh.coordinates():
    x /= numpy.linalg.norm(x)

Q = FunctionSpace(mesh, "DG", 0)
F = interpolate(Expression("x[0]*x[1]", degree=1), Q)

from IPython.display import HTML
xp = X3DOMParameters()
xp.set_color_map("gist_rainbow")
HTML(X3DOM.html(F, xp))


Out[1]:
FEniCS/DOLFIN X3DOM plot
Number of vertices: 642, number of cells: 1280

In [ ]: