Plotting : no windows shows up

Hi all,

I’m trying to show plots with matplotlib. I’ve managed to save the plot to .png but I’d like a window to show up instead.

I’m using the docker current image of FEniCS. Here’s a MWE that run up to completion for me.

from fenics import *
from dolfin import *
import numpy as np
import matplotlib.pyplot as plt

mesh = RectangleMesh(Point(-5, -5), Point(5, 5), 50, 50)
V = FunctionSpace(mesh, 'P', 1)

def boundary(x, on_boundary):
    return on_boundary

bc = DirichletBC(V, 0, boundary)

u = Function(V)
v = TestFunction(V)
f = Expression('1/4*pow(x[0], 2) + 9*pow(x[1], 2)', degree=2)

F = dot(grad(u), grad(v))*dx - f*v*dx

solve(F == 0, u, bc)


Any chance this thread helps?

Specifically this link.


# ...
from vtkplotter.dolfin import plot, screenshot
plot(u, cmap='viridis', lw=0)


plot(u, cmap='viridis', lw=0, warpZfactor=.01)

documentation is here.

Hi, unfortunately I couldn’t find an easy fix so I thought I’d better open a new thread. I was able a while ago to use the matplotlib gui inside a container so I reckon there might be something wrong in either my fenics installation or something else