# Plotting 2D Isosurface in Python

**URL:** https://discourse.vtk.org/t/plotting-2d-isosurface-in-python/2577
**Category:** Support
**Created:** [February 11, 2020, 2:01pm UTC](https://discourse.vtk.org/t/plotting-2d-isosurface-in-python/2577 "2020-02-11T14:01:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RSwn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/f05b48/32.png) [@RSwn](https://discourse.vtk.org/u/RSwn)
#### Post date: [February 11, 2020, 2:01pm UTC](https://discourse.vtk.org/t/plotting-2d-isosurface-in-python/2577/1 "2020-02-11T14:01:06Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 12, 2020, 1:14am UTC](https://discourse.vtk.org/t/plotting-2d-isosurface-in-python/2577/2 "2020-02-12T01:14:28Z")

</div>

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](https://docs.pyvista.org) might be helpful as it has a convenient helper for these contour filters: [https://docs.pyvista.org/examples/01-filter/contouring.html#iso-surfaces](https://docs.pyvista.org/examples/01-filter/contouring.html#iso-surfaces)

---

<div class="post-metadata">

### Author: ![RSwn](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/r/f05b48/32.png) [@RSwn](https://discourse.vtk.org/u/RSwn)
#### Post date: [February 12, 2020, 8:13pm UTC](https://discourse.vtk.org/t/plotting-2d-isosurface-in-python/2577/3 "2020-02-12T20:13:23Z")

</div>

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:

```
N=-0.5*(dudx **2+dvdy** 2+dwdz**2)- 
dudy-dvdx

```

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