Segment Drawing Primitives¶
Schemdraw drawing segments.
Each element is made up of one or more segments that define drawing primitives.
-
class
schemdraw.segments.
Segment
(path: Sequence[Union[Sequence[float], schemdraw.util.Point]], color: Optional[str] = None, lw: Optional[float] = None, ls: Optional[Literal[-, :, --, -.]] = None, capstyle: Optional[Literal[butt, round, square, projecting]] = None, joinstyle: Optional[Literal[bevel, miter, round]] = None, fill: Optional[str] = None, zorder: Optional[int] = None)¶ A segment path
- Parameters
path – List of (x,y) coordinates making the path
color – Color for this segment
lw – Line width for the segment
ls – Line style for the segment ‘-‘, ‘–’, ‘:’, etc.
capstyle – Capstyle for the segment: ‘butt’, ‘round’, ‘square’, (‘projecting’)
joinstyle – Joinstyle for the segment: ‘round’, ‘miter’, or ‘bevel’
fill – Color to fill if path is closed
zorder – Z-order for segment
-
doflip
() → None¶ Vertically flip the element
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the center of the path)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
(xmin, ymin, xmax, ymax)
- Return type
Bounding box limits
-
class
schemdraw.segments.
SegmentArc
(center: Sequence[float], width: float, height: float, theta1: float = 35, theta2: float = -35, arrow: Optional[Literal[cw, ccw]] = None, angle: float = 0, color: Optional[str] = None, lw: Optional[float] = None, ls: Optional[Literal[-, :, --, -.]] = None, zorder: Optional[int] = None)¶ An arc drawing segment
- Parameters
center – Center of the arc ellipse
width – Width of the arc ellipse
height – Height of the arc ellipse
theta1 – Starting angle in degrees
theta2 – Ending angle in degrees
angle – Rotation of the ellipse defining the arc
arrow – Direction of arrowhead (‘cw’ or ‘ccw’)
color – Color for this segment
lw – Line width for the segment
ls – Line style for the segment
fill – Color to fill if path is closed
zorder – Z-order for segment
-
doflip
() → None¶ Vertically flip the element
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the centerx point)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
Bounding box limits (xmin, ymin, xmax, ymax)
-
xform
(transform, **style) → SegmentArc¶ Return a new Segment that has been transformed to its global position
- Parameters
transform – Transformation to apply
style – Style parameters from Element to apply as default
-
class
schemdraw.segments.
SegmentArrow
(tail: Sequence[float], head: Sequence[float], headwidth: Optional[float] = None, headlength: Optional[float] = None, color: Optional[str] = None, lw: Optional[float] = None, ref: Optional[Literal[start, end]] = None, zorder: Optional[int] = None)¶ An arrow drawing segment
- Parameters
tail – Start coordinate of arrow
head – End coordinate of arrow
headwidth – Width of arrowhead
headlength – Length of arrowhead
color – Color for this segment
lw – Line width for the segment
ls – Line style for the segment
zorder – Z-order for segment
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the centerx point)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
Bounding box limits (xmin, ymin, xmax, ymax)
-
xform
(transform, **style) → SegmentArrow¶ Return a new Segment that has been transformed to its global position
- Parameters
transform – Transformation to apply
style – Style parameters from Element to apply as default
-
class
schemdraw.segments.
SegmentCircle
(center: Sequence[float], radius: float, color: str = None, lw: float = None, ls: Linestyle = None, fill: bool | str | None = None, zorder: int = None, ref: Literal[start, end] = None)¶ A circle drawing segment
- Parameters
center – (x, y) center of the circle
radius – Radius of the circle
color – Color for this segment
lw – Line width for the segment
ls – Line style for the segment
fill – Color to fill if path is closed. True -> fill with element color.
zorder – Z-order for segment
ref – Flip reference [‘start’, ‘end’, None].
-
doflip
() → None¶ Flip the segment up/down
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the centerx point)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
Bounding box limits (xmin, ymin, xmax, ymax)
-
xform
(transform, **style) → SegmentCircle¶ Return a new Segment that has been transformed to its global position
- Parameters
transform – Transformation to apply
style – Style parameters from Element to apply as default
-
class
schemdraw.segments.
SegmentPoly
(verts: Sequence[Sequence[float]], closed: bool = True, cornerradius: float = 0, color: Optional[str] = None, fill: Optional[str] = None, lw: Optional[float] = None, ls: Optional[Literal[-, :, --, -.]] = None, joinstyle: Optional[Literal[bevel, miter, round]] = None, capstyle: Optional[Literal[butt, round, square, projecting]] = None, zorder: Optional[int] = None)¶ A polygon segment
- Parameters
xy – List of (x,y) coordinates making the polygon
closed – Draw a closed polygon (default True)
cornerradius – Round the corners to this radius (0 for no rounding)
color – Color for this segment
lw – Line width for the segment
ls – Line style for the segment
fill – Color to fill if path is closed
zorder – Z-order for segment
-
doflip
() → None¶ Vertically flip the element
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the centerx point)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
Bounding box limits (xmin, ymin, xmax, ymax)
-
xform
(transform, **style) → SegmentPoly¶ Return a new Segment that has been transformed to its global position
- Parameters
transform – Transformation to apply
style – Style parameters from Element to apply as default
-
class
schemdraw.segments.
SegmentText
(pos: Sequence[float], label: str, align: Optional[Tuple[Optional[Literal[center, left, right]], Optional[Literal[center, top, bottom]]]] = None, rotation: Optional[float] = None, rotation_mode: Optional[Literal[anchor, default]] = None, color: Optional[str] = None, fontsize: float = 14, font: Optional[str] = None, zorder: Optional[int] = None)¶ A text drawing segment
- Parameters
pos – (x, y) coordinates for text
label – Text to draw
align – Tuple of (horizontal, vertical) alignment where horizontal is (‘center’, ‘left’, ‘right’) and vertical is (‘center’, ‘top’, ‘bottom’)
rotation – Rotation angle in degrees
rotation_mode – See Matplotlib documentation. ‘anchor’ or ‘default’.
color – Color for this segment
fontsize – Font size
font – Font name/family
zorder – Z-order for segment
-
doflip
() → None¶ Vertically flip the element
-
doreverse
(centerx: float) → None¶ Reverse the path (flip horizontal about the centerx point)
-
draw
(fig, transform, **style) → None¶ Draw the segment
- Parameters
fig – schemdraw.Figure to draw on
transform – Transform to apply before drawing
style – Default style parameters
-
get_bbox
() → schemdraw.types.BBox¶ Get bounding box (untransformed)
- Returns
Bounding box limits (xmin, ymin, xmax, ymax)
-
xform
(transform, **style) → SegmentText¶ Return a new Segment that has been transformed to its global position
- Parameters
transform – Transformation to apply
style – Style parameters from Element to apply as default