-
First check
Commit to Help
Sample Code What is the problem, question, or error?Write a short description telling me what you are doing, what you expect to happen, and what is currently happening. import pyvista as pv
import numpy as np
point_cloud = pv.PolyData(np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]]))
pl = pv.Plotter(
shape=(2, 2),
# off_screen=True,
# Disable lighting to see difference between points_gaussian and points lighting
lighting=None,
)
for i, style in enumerate(["points", "points_gaussian"]):
for j, zoom in enumerate([1.0, 3.0]):
pl.subplot(i, j)
actor = pl.add_mesh(
point_cloud.copy(),
point_size=50,
render_points_as_spheres=True,
emissive=False,
style=style,
)
pl.camera_position = "xy"
pl.camera.zoom(zoom)
pl.add_text(f"{style} {'far' if zoom == 1.0 else 'close'}")
# pl.screenshot("experiments/pyvista_points.png")
pl.show() DescriptionI'm essentially looking for two behaviors when visualizing point clouds, and I figured out how to find each independently, but not jointly:
I've found that Is there a way to enable custom lighting for System Information--------------------------------------------------------------------------------
Date: Thu Aug 28 21:41:27 2025 EDT
OS : Linux (Ubuntu 20.04)
CPU(s) : 24
Machine : x86_64
Architecture : 64bit
Environment : Python
GPU Vendor : NVIDIA Corporation
GPU Renderer : NVIDIA GeForce RTX 3090/PCIe/SSE2
GPU Version : 4.5.0 NVIDIA 535.261.03
Render Window : vtkXOpenGLRenderWindow
MathText Support : True
Python 3.11.9 (main, Aug 14 2024, 05:07:28) [Clang 18.1.8 ]
pyvista : 0.46.3
vtk : 9.5.0
numpy : 2.3.0
matplotlib : 3.10.3
scooby : 0.10.1
pooch : 1.8.2
pillow : 11.2.1
scipy : 1.16.1
tqdm : 4.67.1
-------------------------------------------------------------------------------- Screenshots![]() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think You can create many spheres using import pyvista as pv
import numpy as np
point_cloud = pv.PolyData(np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]]))
point_cloud.glyph(geom=pv.Sphere()).plot() ![]() EDIT: Here's a more complete example with import pyvista as pv
import numpy as np
point_cloud = pv.PolyData(np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]]))
pl = pv.Plotter(shape=(1, 2))
for i, zoom in enumerate([1.0, 3.0]):
pl.subplot(0, i)
pl.add_mesh(point_cloud.glyph(geom=pv.Sphere()), smooth_shading=True)
pl.camera_position = "xy"
pl.camera.zoom(zoom)
pl.add_text(f"{'far' if zoom == 1.0 else 'close'}")
pl.show() ![]() |
Beta Was this translation helpful? Give feedback.
I think
render_points_as_spheres
andpoints_gaussian
both use rendering tricks under the hood to make the points look like spheres without actually being spheres. Using actual geometric spheres is helpful because the point normals are computed and used for shading, and will zoom in and out as desired.You can create many spheres using
glyph
:EDIT: Here's a more complete example with
smooth_shading
enabled.