Plotting API
skelarm.plotting
Provides utility functions for plotting robot arm states and trajectories.
draw_skeleton(ax, skeleton, color=_LINK_COLOR, linewidth=1.5, *, base_color=_BASE_LINK_COLOR, joint_color=_JOINT_COLOR, show_com=False, com_color=_COM_COLOR, label=None, title='Robot Arm Skeleton')
Draw the robot arm skeleton on a given Matplotlib Axes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
The Matplotlib Axes object to draw on. |
required |
skeleton
|
Skeleton
|
The Skeleton object containing the robot arm's links. |
required |
color
|
str
|
Color of the movable robot arm links (defaults to the GUI's blue). |
_LINK_COLOR
|
linewidth
|
float
|
Width of the lines representing the links. |
1.5
|
base_color
|
str
|
Color of the fixed base link ( |
_BASE_LINK_COLOR
|
joint_color
|
str
|
Color of the joint markers (defaults to the GUI's green). The origin is always drawn black, matching the GUI. |
_JOINT_COLOR
|
show_com
|
bool
|
When |
False
|
com_color
|
str
|
Color of the center-of-mass markers (defaults to red). |
_COM_COLOR
|
label
|
str | None
|
Legend label for the arm. When given, a single legend entry is added and
the legend is shown; when |
None
|
title
|
str | None
|
Axes title. Pass |
'Robot Arm Skeleton'
|
Source code in src/skelarm/plotting.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
draw_target(ax, position, *, color=_GOAL_COLOR, tolerance=None, active=True, label=None)
Draw a task target marker matching the interactive player's canvas overlay.
Mirrors :meth:skelarm.canvas.SkelarmCanvas._draw_target_marker so a static
Matplotlib plot shows the goal exactly as the live GUI / replay player does. An
active target is a filled dot inside a hollow ring; an inactive one (a
multi-target candidate not currently sought) is a dashed hollow ring with no
fill. The ring is drawn at the success tolerance radius in data space when
given, otherwise as a small fixed-size marker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
The Matplotlib Axes object to draw on. |
required |
position
|
NDArray[np.float64] or sequence of float
|
Target |
required |
color
|
str
|
Marker color (defaults to the GUI's purple, matching the task's default color and the player overlay). |
_GOAL_COLOR
|
tolerance
|
float | None
|
Success radius in meters. When given, the ring is a circle of this data-space
radius; when |
None
|
active
|
bool
|
Draw the filled-dot-plus-ring active style (default). When |
True
|
label
|
str | None
|
Legend label for the target, added to a single artist. |
None
|
Source code in src/skelarm/plotting.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
plot_trajectory(ax, trajectory_x, trajectory_y, color='red', linestyle='-', linewidth=1.0, *, label='Tip Trajectory', title='Tip Trajectory')
Plot a 2D trajectory on a given Matplotlib Axes object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Axes
|
The Matplotlib Axes object to draw on. |
required |
trajectory_x
|
NDArray[float64]
|
Array of x-coordinates for the trajectory. |
required |
trajectory_y
|
NDArray[float64]
|
Array of y-coordinates for the trajectory. |
required |
color
|
str
|
Color of the trajectory line. |
'red'
|
linestyle
|
str
|
Style of the trajectory line (e.g., '-', '--', ':'). |
'-'
|
linewidth
|
float
|
Width of the trajectory line. |
1.0
|
label
|
str
|
Legend label for the trajectory. |
'Tip Trajectory'
|
title
|
str | None
|
Axes title. Pass |
'Tip Trajectory'
|