# Examples from pyvista.PolyDataFilters.decimate_binned
# =====================================================

# Decimate a sphere to roughly 2000 points and plot it.
import pyvista as pv
sphere = pv.Sphere(theta_resolution=200, phi_resolution=200)
decimated = sphere.decimate_binned(target_points=2000)
decimated.plot(show_edges=True, line_width=2)

# Remove about 90% of the points.
decimated = sphere.decimate_binned(0.9)

# Use an explicit bin grid, averaging the points in each bin.
decimated = sphere.decimate_binned(
    divisions=20, point_generation='bin_averages'
)

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
