Reputation: 21
I have a set of 3D data from a CFD simulation in the .vtk format. To plot the values of one set of point data, I wanted to use the plot_over_line functionality from pyvista. This works in general fine, no issue with that when following a similar approach as in the example (https://docs.pyvista.org/version/stable/examples/02-plot/plot-over-line#sphx-glr-examples-02-plot-plot-over-line-py):
#Load mesh
mesh = examples.download_kitchen()
#Make points
a = [mesh.bounds[0], mesh.bounds[2], mesh.bounds[4]]
b = [mesh.bounds[1], mesh.bounds[3], mesh.bounds[5]]
#Make line
line = pv.Line(a, b)
#Plot
test = mesh.plot_over_line(a, b, resolution=100)
However, what I would prefer to do is to extract the date (x and y values) that is plotted by the plot_over_line function because having the data extracted would give me much more flexibility for plotting it afterwards (colors, comparing to other solutions, etc. How can I achieve that??
Upvotes: 0
Views: 258
Reputation: 620
You want sample_over_line
for simple line sampling. plot_over_line
uses sample_over_line
under the hood. See https://github.com/pyvista/pyvista/blob/3d6e327a7c43d9035ad54de936228f3ac7c5a88a/pyvista/core/filters/data_set.py#L4440-L4442. Note that 'Distance'
is added to the data in case you need it for further processing.
If you need even more flexibility, like sampling at points with arbitrary intervals along a line, you can use sample
. sample_over_line
uses sample
under the hood. See https://github.com/pyvista/pyvista/blob/3d6e327a7c43d9035ad54de936228f3ac7c5a88a/pyvista/core/filters/data_set.py#L4369.
Upvotes: 1