Skip to content

Instantly share code, notes, and snippets.

@krystophny
Created May 7, 2019 11:13
Show Gist options
  • Save krystophny/976931461205f9334a76e2c4f1808061 to your computer and use it in GitHub Desktop.
Save krystophny/976931461205f9334a76e2c4f1808061 to your computer and use it in GitHub Desktop.
Plotting on a mesh
import matplotlib.pyplot as plt
import matplotlib.tri as mpltri
import meshio # von https://github.com/nschloe/meshio
mesh = meshio.read('any_known_mesh_format.msh')
tria = mpltri.Triangulation(mesh.points[:,0], mesh.points[:,1], mesh.cells['triangle'])
for k in range(nplots):
plt.figure()
plt.tricontourf(tria, plot_data[k])
plt.colorbar()
plt.savefig('fig_{:03}.pdf'.format(k))
# wenn was interpoliert werden soll
datafun = mpltri.LinearTriInterpolator(tria, data_on_points)
wert = datafun(x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment