Skip to content

Shapes 3d

subsurfaceio.plotly_utils.shapes_3d

Three-dimensional Plotly surface primitives.

Assemble boxes and capped cylinders from flat-colored Surface traces, used by the foundation geometry plots.

Functions:

Name Description
box_from_opposite_corners

Add an axis-aligned box spanning two opposite corners.

cylinder_with_caps

Add a closed vertical cylinder with both end caps.

Attributes:

Name Type Description
CYLINDER_RESOLUTION int

Default number of segments used to discretize curved surfaces.

Mesh TypeAlias

x/y/z coordinate grids describing a single surface.

CYLINDER_RESOLUTION module-attribute

CYLINDER_RESOLUTION: int = 25

Default number of segments used to discretize curved surfaces.

Mesh module-attribute

Mesh: TypeAlias = dict[str, Any]

x/y/z coordinate grids describing a single surface.

box_from_opposite_corners

box_from_opposite_corners(
    pt1: Sequence[float],
    pt2: Sequence[float],
    color: str = "blue",
    opacity: float = 0.5,
    legendgroup: str | None = None,
    showlegendgrouptitle: bool = False,
    single_legend_entry: bool = True,
    fig: Figure | None = None,
) -> go.Figure

Add an axis-aligned box spanning two opposite corners.

Parameters:

Name Type Description Default
pt1 Sequence[float]

One corner as (x, y, z).

required
pt2 Sequence[float]

The diagonally opposite corner as (x, y, z).

required
color str

Flat fill color.

'blue'
opacity float

Surface opacity.

0.5
legendgroup str | None

Legend group shared by the box's six faces.

None
showlegendgrouptitle bool

Show legendgroup as the legend group title.

False
single_legend_entry bool

Emit one legend entry for the box rather than one per face.

True
fig Figure | None

Figure to add to; a new one is created when None.

None

Returns:

Type Description
Figure

The figure the box was added to.

cylinder_with_caps

cylinder_with_caps(
    x: float,
    y: float,
    z: float,
    r: float,
    dz: float,
    res: int = CYLINDER_RESOLUTION,
    color: str = "blue",
    opacity: float = 0.5,
    legendgroup: str | None = None,
    showlegendgrouptitle: bool = False,
    single_legend_entry: bool = True,
    fig: Figure | None = None,
) -> go.Figure

Add a closed vertical cylinder with both end caps.

Parameters:

Name Type Description Default
x float

Center abscissa.

required
y float

Center ordinate.

required
z float

Elevation of the cylinder base.

required
r float

Radius.

required
dz float

Height.

required
res int

Number of segments used to discretize the curved surfaces.

CYLINDER_RESOLUTION
color str

Flat fill color.

'blue'
opacity float

Surface opacity.

0.5
legendgroup str | None

Legend group shared by the lateral surface and both caps.

None
showlegendgrouptitle bool

Show legendgroup as the legend group title.

False
single_legend_entry bool

Emit one legend entry for the cylinder rather than one per surface.

True
fig Figure | None

Figure to add to; a new one is created when None.

None

Returns:

Type Description
Figure

The figure the cylinder was added to.