Plotting 2D Isosurface in Python

I am looking to plot a 2D isosurface using VTK in Python. I am trying to visualise the Q-Criterion in Paraview but am looking to build the isosurface into the file rather than using the Paraview option. I couldn’t find much information on whether VTK has a function for this or if there is another alternative. Any suggestions?

What kind of mesh are you starting with?

You can use the vtk.vtkContourFilter, vtk.vtkMarchingCubes, and vtk.vtkFlyingEdges3D to contour (make an isosurface) of 3D data.

Also, if you’re in Python and just getting started with VTK, PyVista might be helpful as it has a convenient helper for these contour filters:

I’m using an unstructured mesh being read from a VTK file. Looking to plot an isosurface of a function I have defined and display it over one of my arrays I have added to the file. Would vtkContourFilter be best since I only need a 2D contour just now? For example if I have my defined function plotted as:


And I just wanted to plot a 2D contour of N=1 over this to view in Paraview?