Creating a 3D surface graph using Paraview

Shabbir Bawaji
4 min readJan 30, 2021

Paraview is a visualization software that is accelerated computing and distributed computing friendly. In today's age of big data generating the data is very much simple but the operations to be performed on these huge datasets is very time consuming and an Intel i9 is also not sufficient enough even if the operations are parallelized.

Not only does Paraview help visualize the in a 3D space but also uses accelerated computing, and yes it is compatible with GPUs other than NVidia as well.

Now, let us see how can we visualize a pyramid in Parview. Assume we have a data in 50x50 matrix and now we want to visualize this data.

One way to do this is using heat-map

An inverted pyramid represented in the form of heat-map

Looking at this image we can point what the value is at a given point but, does it give us an idea of how overall the matrix represents in the first look itself

Let’s look at it this way, that we have information of where the exact value is in the 2D space but, what if we represented these values at a given X, Y position as height in the Z-axis. This helps us in modelling the data in the 3D space. So a point will be represented as [X, Y, Z].

Now let us see how we can plot these points using Paraview.

There are number of ways Paraview takes data as input including VKT and CSV. Let us see how to use the CSV file.

Firstly, the CSV file must have 3 columns x_position, y_position and value and then fill the columns accordingly

This would be for all the positions of x and y

Step 1: open Paraview

Step 2: open your CSV file. Do this by going to the Tool barFileOpen (shortcut: + O) and then select the CSV with your data and then open it.

Our pipeline should then look something like

Step 3: Apply ‘Table to Points’ filter. Just right click on the CSV file object.

And under Add Filter → Alphabetical select Table to Points

Step4: Once you have applied the Table to Points filter you need to identify your axis columns. So select x_position as X column, y_position as Y Column and value as Z Column

In some versions, Paraview automatically applies your changes but sometimes it doesn’t. So do click the apply button to apply your property changes.

Step 5: Apply the Delaunay2D filter on your TableToPoint object. Let’s do this by right clicking the TableToPoint object and then Add FilterAlphabeticalDelaunay 2D and then click Apply.

And voilà we have our pyramid.

Note: If Paraview is rendering using CPU and not openGL and GPU then it might take sometime in rendering your object so you might need to be patient.

Step 6: Add axis grid to it. Under Properties → View → Check Axes Grid.

And you should be able to see the axises

This was a simple example of visualization of a pyramid structure. However, once we have the CSV we can visualize the complex of the structures that are formed by our dataset. Below is an example of cosine wave in 2D space.

Video is generated using matplotlib animation. This is a 2D video of cosine wave function over time.
Video is generated using Paraview. This is a 3D video of cosine wave function over time.

The question to ask ourselves is that which visualization is more intuitive for us and get a better idea of what is happening in the 3D space of our dataset?

The above visualizations were created using the user interface provided by Paraview, which may seem easy while applying 2–3 filters, but what if you have to incorporate the above filters among many other operations as well, and that too for various datasets. What to do then?

The solution is further automation. Paraview provides a Python shell using which we can add the filters and operations programatically.

Below is the code to apply the above filters using Python.

from paraview.simple import *def to_surface_graph(path_to_csv_file):
csv = CSVReader(FileName=path_to_csv_file)
points = TableToPoints(
csv,
XColumn='X',
YColumn='Y',
ZColumn='Z',
KeepAllDataArrays=True
)
return Delaunay2D(points)

--

--