Plotting particular line in a mesh

Hi

I was wondering if it is possible to plot a particular part of the mesh rather than the whole thing.

For example in the example for the Poisson equation in the iTutorials (Poisson Equation — NGS-Py 6.2.2302 documentation) how would I go about only plotting a line for the solution on y=0.5. I imagine id probably need to use matplotlib to do the plot but I’m not sure how to take the right data from gfu.vec.

Thanks
Katie

Hi Katie,

you have to evaluate gfu at the desired points, this can be done by “gfu(mesh(x,y))”.
As you suggested, it is probably the easiest to use matplotlib to plot the data.

import matplotlib.pyplot as plt
N = 100
xpnts = [i/N for i in range(N+1)]
vals = [gfu(mesh(xi,0.5)) for xi in xpnts]
plt.plot(xpnts,vals)
plt.show(block=False)

Best,
Christoph

Great, that works! Thanks