PolyDataFilters.dash_lines

PolyDataFilters.dash_lines#

PolyDataFilters.dash_lines(
style: LineStyle | None = None,
*,
pattern: VectorLikeFloat | None = None,
scale: float | None = None,
join: bool = True,
inplace: bool = False,
progress_bar: bool = False,
) → PolyData[source]#

Split line cells into dashes.

Line and polyline cells are resampled into shorter line cells following a repeating on-off pattern. Only those cells are returned, so vertices, polygons and strips are removed.

Point data is interpolated onto the dash end points. Cell data is copied from the parent line cell, unless join merges those cells together.

Added in version 0.50.

Parameters:
stylestr, optional

Named dash pattern, one of:

  • '': hidden, returning no lines at all.

  • '-': solid, returning the lines whole.

  • '--': dashed, equivalent to pattern=[8, 8].

  • ':': dotted, equivalent to pattern=[1, 7, 1, 7].

  • '-.': dash-dot, equivalent to pattern=[4, 6, 2, 4].

  • '-..': dash-dot-dot, equivalent to pattern=[3, 3, 1, 3, 3, 3].

Every named style repeats over sixteen intervals. Defaults to '--'. Cannot be set together with pattern.

patternVectorLikeFloat, optional

Lengths of alternating drawn and undrawn intervals, starting with a drawn one and repeating. [4, 6, 2, 4] draws four intervals, skips six, draws two and skips four. Cannot be set together with style.

scalefloat, optional

Length of one pattern interval in world units. Defaults to length divided by 200.

joinbool, default: True

Join connected line cells into polylines with strip() first so the pattern runs continuously across them. Joined cells have no cell data of their own, so the input’s cell data is dropped.

inplacebool, default: False

Update this dataset in place. When False, return a new dataset.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

Dataset holding the dashes as its only cells.

Notes#

Line styles#

Style

Description

Example

""

Hidden

../../../_images/ls_0.png

"-"

Solid

../../../_images/ls_1.png

"--"

Dashed

../../../_images/ls_2.png

":"

Dotted

../../../_images/ls_3.png

"-."

Dash-dot

../../../_images/ls_4.png

"-.."

Dash-dot-dot

../../../_images/ls_5.png

Examples#

Download Python source code | Download Jupyter notebook

Dash a circle.

>>> import pyvista as pv
>>> circle = pv.Circle(resolution=200).extract_all_edges()
>>> circle.dash_lines().plot(color='black', line_width=4, cpos='xy')
../../../_images/pyvista-PolyDataFilters-dash_lines-f45fdcc7f748b7e5_00_00.png

Use a long dash and a short one instead of a named style.

>>> dashed = circle.dash_lines(pattern=[6, 2, 2, 2])
>>> dashed.plot(color='black', line_width=4, cpos='xy')
../../../_images/pyvista-PolyDataFilters-dash_lines-f45fdcc7f748b7e5_01_00.png

See Also#

pyvista.PolyDataFilters.strip

Join connected line cells into polylines.

pyvista.PolyDataFilters.tube

Generate a tube around each input line.

pyvista.Actor.line_style

Dash an actor’s lines in the shader instead of splitting the cells.