This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to enable plot?

+4 votes

I am learning FEniCS. I have a problem, when I run the example ft01_poisson.py.
Although there is plot(u) and plot(mesh) in the code, it doesn't give the plot figure when I run it. In the tutorial book FEniCS tutorial vol1, page18, it also says

If plotting is enabled in your FEniCS installation, then a window with a simple plot of the solution will appear as in Figure 2.1.

It seems that the plotting is not enabled in my FEniCS. If so, how can I enable it.
PS: I installed FEniCS through conda.

asked Feb 13, 2017 by Bingxiao FEniCS Novice (200 points)
edited Feb 14, 2017 by Bingxiao

1 Answer

+1 vote

Do you call it in a python shell? Then you probably have to add

import matplotlib.pyplot as plt
plt.show()

somewhere (after the fenics plot commands)...

answered Feb 14, 2017 by Jan FEniCS User (8,290 points)

This doesn't work for me. When I type

plt.show()

nothing happens.

I try to go to http://127.0.0.1:3001, but get the message (from Chrome):

The 127.0.0.1 page isn’t working

127.0.0.1 didn’t send any data.
ERR_EMPTY_RESPONSE

Now I uninstall Anaconda, and install FEniCS through the command given in FEniCS on Ubuntu , then the example ft01_poisson.py can plot. So it seems like the conda-package given in conda-release is unable to use the plot function.

OK. Sorry to hear that. Same thing, when you run the example below???

import dolfin
import matplotlib.pyplot as plt

N = 5
sqmesh = dolfin.UnitSquareMesh(N, N+1)
plt.plot(1)
plt.show()
dolfin.plot(sqmesh)
plt.show()

Thank you for your response. I just tried those exact lines and I still get the same result:

ERR_EMPTY_RESPONSE
...