<jupyter_start><jupyter_text>Label Points============Use string arrays in a point set to label points<jupyter_code># sphinx_gallery_thumbnail_number = 3
from pyvista import examples
import pyvista as pv
import numpy as np<jupyter_output><empty_output><jupyter_text>Label String Array==================This example will label the nodes of a mesh with a given array of stringlabels for each of the nodes.<jupyter_code># Make some random points
poly = pv.PolyData(np.random.rand(10, 3))<jupyter_output><empty_output><jupyter_text>Add string labels to the point data - this associates a label with everynode:<jupyter_code>poly["My Labels"] = [f"Label {i}" for i in range(poly.n_points)]
poly<jupyter_output><empty_output><jupyter_text>Now plot the points with labels:<jupyter_code>plotter = pv.Plotter()
plotter.add_point_labels(poly, "My Labels", point_size=20, font_size=36)
plotter.show()<jupyter_output><empty_output><jupyter_text>Label Node Locations====================This example will label the nodes of a mesh with their coordinatelocations<jupyter_code># Load example beam file
grid = pv.UnstructuredGrid(examples.hexbeamfile)<jupyter_output><empty_output><jupyter_text>Create plotting class and add the unstructured grid<jupyter_code>plotter = pv.Plotter()
plotter.add_mesh(grid, show_edges=True, color="tan")

# Add labels to points on the yz plane (where x == 0)
points = grid.points
mask = points[:, 0] == 0
plotter.add_point_labels(
    points[mask], points[mask].tolist(), point_size=20, font_size=36
)

plotter.camera_position = [
    (-1.5, 1.5, 3.0),
    (0.05, 0.6, 1.2),
    (0.2, 0.9, -0.25)]

plotter.show()<jupyter_output><empty_output><jupyter_text>Label Scalar Values===================This example will label each point with their scalar values<jupyter_code>mesh = examples.load_uniform().slice()
p = pv.Plotter()

# Add the mesh:
p.add_mesh(mesh, scalars="Spatial Point Data", show_edges=True)
# Add the points with scalar labels:
p.add_point_scalar_labels(mesh, "Spatial Point Data", point_size=20, font_size=36)

# Use a nice camera position:
p.camera_position = [(7, 4, 5), (4.4, 7.0, 7.2), (0.8, 0.5, 0.25)]

p.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14574712643678162, 'fraction_numerical': 0.02528735632183908, 'mean_word_length': 6.689045936395759, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '139047', 'license': 'MIT', 'n_tokens_mistral': 801, 'n_tokens_neox': 758, 'n_words': 198, 'path': 'notebooks/official/labels.ipynb', 'repo_name': 'kmch/pyvista-examples', 'size': '2175'}