I would like to add points (and cells) to the pyvista.PolyData
in the plotter. I tried using the Plotter.update_coordinates
function however this is only useful for point data with equal size:
import numpy as np
import pyvista as pv
import pyvistaqt
points = np.array([[1, 0, 0],
[2, 0, 0],
[3, 0, 0]])
point_cloud = pv.PolyData(points)
plotter = pyvistaqt.BackgroundPlotter()
a = plotter.add_points(point_cloud)
plotter.show()
new_points = np.array([[1, 0, 0],
[2, 0, 0],
[5, 0, 0],
[7, 0, 0]]) # Not updated in the plotter
plotter.update_coordinates(new_points, point_cloud, render=True)
It seems the points are updated, however not the cells. Hence, only the corresponding cells are modified in the plotter.
What is the best practice to update the PolyData, which includes new (additional) points?
You said
But this is not clear to me. You have two options: either add further points to a
PolyData
and then plot that one mesh, or you can add two differentPolyData
objects to the same plotter.Here are the two options:
And as a side note, if you only have a point cloud (i.e. no cells) you should consider using the new
PointSet
class. This needs PyVista 0.34.0 and VTK 9.1.0 or higher.