Skip to content
This repository was archived by the owner on Apr 17, 2026. It is now read-only.
This repository was archived by the owner on Apr 17, 2026. It is now read-only.

sample_over_line produces spurious zero values in UnstructuredGrid #201

@fbeaudo

Description

@fbeaudo

Description

I am working with an UnstructuredGrid and I want to plot the quantity over a line. The quantity (called 'eps') is defined at the nodes of the grid.
I saved the .vtk file for my grid (see below). Plotting the quantity gives me the result I expect. The same is true using slices. These two methods both give me a value that is non-zero everywhere.
However, if I produce a linecut of the same quantity 'eps' using the sample_over_line method, then some spurious zeros appear in the output data. This can also be seen using plot_over_line.
This appears to be a bug, since my quantity should not be zero along this linecut. This can easily be seen from the 3D plots.
I am using pyvista version 0.25.3 along with vtk version 9.0.1. I had the same issue with pyvista 0.24.2. I would appreciate to know what could be causing this.
Here is the code that shows the apparent bug.

""" sample_over_line.py: Test pyvista function sample_over_line."""

__author__ = "Felix Beaudoin"
__copyright__ = "Copyright 2020, Nanoacademic Technologies Inc."

import pyvista as pv

# Load vtk file and initialize grid
path = "pyvistagrid.vtk"
grid = pv.UnstructuredGrid(path)

# Plot the quantity 'eps' stored in .vtk file
# It is clearly non-zero everywhere
# This is also true when inspecting the .vtk file
grid.plot()
slices = grid.slice_orthogonal()
slices.plot()

# Now plot over a line from x=-12e-9 to x=12e-9 at z=5e-9 and y=0.
begin = [-12e-9,0,5e-9]
end = [12e-9,0,5e-9]
grid.plot_over_line(begin,end,resolution=100)

# The plot shows dips at which 'eps' goes to 0 exactly
# This is also seen by directly printing the linecut
linecut = grid.sample_over_line(begin,end,resolution=100)
print(linecut.point_arrays['eps'])

Example Data

The vtk file used in the code is also attached in the following zip file.
pyvistagrid.zip

Metadata

Metadata

Assignees

Labels

filteringGeneral topics around filtering and usage of filters

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions