- Thank you received: 0
Plotting particular line in a mesh
3 years 11 months ago #3430
by bakerk
Plotting particular line in a mesh was created by bakerk
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 ( ngsolve.org/docu/latest/i-tutorials/wta/poisson.html ) 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
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 ( ngsolve.org/docu/latest/i-tutorials/wta/poisson.html ) 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
3 years 11 months ago #3431
by cwinters
Replied by cwinters on topic Plotting particular line in a mesh
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.
Best,
Christoph
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.
Code:
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
Time to create page: 0.108 seconds