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

Adding axis to plot function

0 votes

Hello All

After creating a mesh, and plotting it, how does one add the axes to the same plot?
Looking at the plot documentation, I see no option for axes.

Thanks,
Victor.

asked Aug 1, 2016 by wtpot FEniCS Novice (450 points)

I've found the "plot" feature for FEniCS to be great for eyeballing / troubleshooting, but not particularly powerful for post-processing. In fact, I'm not sure you can add axes to your plots.

You may want to export your information to numpy arrays for use in matplotlib (or dump them as an organized delimited text file for MATLAB.)

1 Answer

+2 votes
 
Best answer

yes,

from dolfin import *
mesh = RectangleMesh(Point(0.,0.),Point(2.,1.), 20,10)
from pylab import show, triplot
coords = mesh.coordinates()
triplot(coords[:,0], coords[:,1], triangles=mesh.cells())
show()

works great in 2D.

For 3D I would suggest paraview.

answered Aug 2, 2016 by KristianE FEniCS Expert (12,900 points)
selected Aug 16, 2016 by johannr

This is perfect. Too bad it only works on 2D.

Thank you.

For 3D I would suggest paraview.

...