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)
plot(u)
plt.show()
plt.savefig('u.png')