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

Add a line to a plot

0 votes

Is there a (hopefully simple) way to plot a mesh and on top of that add some more marks? I'd like to add a line and a big dot to a plot of a mesh.

asked Apr 14, 2016 by Yair Daon FEniCS User (1,350 points)

1 Answer

+1 vote
 
Best answer

In 2D you can just use pylab's triplot

from dolfin import *
from mshr import *
from pylab import triplot, show, hold, plot
c1 = Circle(Point(0.,0.),0.5)
r1 = Rectangle(Point(0.,0.),Point(1.,1.))
mesh = generate_mesh(r1-c1,15)
triplot(mesh.coordinates()[:,0],mesh.coordinates()[:,1],\
triangles=mesh.cells(),color='k')
hold('on'); plot([0.2,0.8],[0.9,0.2],'bo-',\
linewidth=2,markersize=16) ;hold('off')
show()
answered Apr 15, 2016 by KristianE FEniCS Expert (12,900 points)
selected Apr 15, 2016 by Yair Daon
...