Matplotlib plotting backend doesn't handle quadrilateral mesh

I’m using the legacy version of fenics (2019.1.0) because of some dependency problems. And I’d like to plot a Function discretized by discrete Galerkin quadrilateral elements with order zero on my jupyter notebook, that is;

mesh = RectangleMesh.create(
    [Point((0, 0)), Point((Lx, Ly))], [Nx, Ny], CellType.Type.quadrilateral)
F = FunctionSpace(mesh, 'DG', 0)
u = Function(F)



But when I tried to plot them, I got the following error message:

Matplotlib plotting backend doesn't handle quadrilateral mesh.
Possible options are saving the output to XDMF file or using 'x3dom' backend.

Unfortunately, I don’t get the way to select and use ‘x3dom’ backend at all.
Any help please? :sob:

X3dom is a separate file format, see: Bitbucket (

XDMFFile is the most commonly used file format, Which you can open in for instance Paraview.

Matplotlib does not support unstructured quad meshes, and thus support for special cases (i.e. Structured unit squares) has not been added.

In the development version of dolfinx, we have extended plotting support for quads using pyvista, see for instance:


1 Like