Debian Codegraph @

examples/02-plot/plot_over_circular_arc.py

raw
1 """
2 .. _plot_over_circular_arc_example:
3
4 Plot Scalars Over a Circular Arc
5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6
7 Interpolate the scalars of a dataset over a circular arc
8 using :meth:`~pyvista.DataSetFilters.plot_over_circular_arc_normal`.
9
10 """
11
12 # sphinx_gallery_thumbnail_number = 2
13 import pyvista as pv
14 from pyvista import examples
15
16 # sphinx_gallery_start_ignore
17 # labels are not supported in vtk-js
18 PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT = True
19 # sphinx_gallery_end_ignore
20
21 # %%
22 # Volumetric Mesh
23 # +++++++++++++++
24 #
25 # Add the height scalars to a uniform 3D mesh.
26 mesh = examples.load_uniform()
27 mesh['height'] = mesh.points[:, 2]
28
29 # Make two points at the bounds of the mesh and one at the center to
30 # construct a circular arc.
31 normal = [0, 1, 0]
32 bnds = mesh.bounds
33 polar = [bnds.x_min, bnds.y_min, bnds.z_max]
34 center = [bnds.x_min, bnds.y_min, bnds.z_min]
35 angle = 90.0
36
37 # Preview how this circular arc intersects this mesh
38 # with :func:`~pyvista.CircularArcFromNormal`.
39 arc = pv.CircularArcFromNormal(
40 center=center, resolution=100, normal=normal, polar=polar, angle=angle
41 )
42
43 pl = pv.Plotter()
44 pl.add_mesh(mesh, style='wireframe', color='w')
45 pl.add_mesh(arc, color='b')
46 a = arc.points[0]
47 b = arc.points[-1]
48 pl.add_point_labels([a, b], ['A', 'B'], font_size=48, point_color='red', text_color='red')
49 pl.show()
50
51 # %%
52 # Run the filter and produce a line plot.
53 mesh.plot_over_circular_arc_normal(
54 center=center,
55 resolution=100,
56 normal=normal,
57 polar=polar,
58 angle=angle,
59 scalars='height',
60 )
61 # %%
62 # .. tags:: plot