plot_distances
Plotting helpers for distance and plane visualization.
AxisPointsLineConfig
KeyPointsStyle
LineStyle
SpanStyle
add_axis_points_line
add_axis_points_line(
fig: Figure,
axis_points: ndarray,
*,
axis_points_labels: Iterable[str] | None = None,
show_axis_points: bool = True,
axis_points_colors: tuple[str, str] | None = None,
axis_points_size: float | None = None,
line_name: str | None = None,
line_color: str | None = None,
line_width: float | None = None,
line_dash: str | None = None,
config: AxisPointsLineConfig | None = None,
) -> None
Add axis points and connecting line to a figure.
This function adds two traces to the figure: 1. Axis points as markers with text labels (optional) 2. A line connecting the axis points (always plotted)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Figure
|
Plotly figure to update. |
required |
|
ndarray
|
Array of shape (2, 3) containing the axis points. |
required |
|
Iterable[str] | None
|
Optional labels for axis points. Defaults to ["pt0", "pt1"]. |
None
|
|
bool
|
Whether to display axis points markers. Default is True. |
True
|
|
tuple[str, str] | None
|
Two colors for axis points markers (legacy parameter). |
None
|
|
float | None
|
Marker size for axis points (legacy parameter). |
None
|
|
str | None
|
Trace name for axis points line (legacy parameter). |
None
|
|
str | None
|
Line color for axis points line (legacy parameter). |
None
|
|
float | None
|
Line width for axis points line (legacy parameter). |
None
|
|
str | None
|
Dash style for axis points line (legacy parameter). |
None
|
|
AxisPointsLineConfig | None
|
Configuration object for styling. Overrides individual parameters. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If axis_points shape is not (2, 3). |
Source code in src/mechaphlowers/plotting/plot_distances.py
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
add_span_points
add_span_points(
fig: Figure,
span_points: ndarray,
*,
span_name: str | None = None,
span_color: str | None = None,
span_marker_size: float | None = None,
config: SpanStyle | None = None,
) -> None
Add span points to a figure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Figure
|
Plotly figure to update. |
required |
|
ndarray
|
Array of shape (N, 3) containing span points along the line. |
required |
|
str | None
|
Trace name for span points (legacy parameter). |
None
|
|
str | None
|
Marker color for span points (legacy parameter). |
None
|
|
float | None
|
Marker size for span points (legacy parameter). |
None
|
|
SpanStyle | None
|
Configuration object for styling. Overrides individual parameters. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If span_points is not an (N, 3) array. |
Source code in src/mechaphlowers/plotting/plot_distances.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
plot_distance_engine
plot_distance_engine(
distance_engine: DistanceEngine,
distance_result: DistanceResult | None = None,
fig: Figure | None = None,
title_addendum: str | None = None,
plane_scale: float = 10.0,
plane_grid_size: int = 3,
axis_labels: Iterable[str] | None = None,
axis_color: str = 'darkviolet',
curve_color: str = 'darkblue',
plane_color: str = 'gold',
projection_color: str = 'firebrick',
force_layout: bool = True,
show_axis_points: bool = True,
show_curve: bool = True,
show_plane: bool = True,
show_distance_result: bool = True,
show_projections: bool = True,
) -> Figure
Plot DistanceEngine components including axis, curve, plane, and distance result.
This function creates a comprehensive 3D visualization of the DistanceEngine, showing the axis line, curve points, optional plane, and distance calculations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
DistanceEngine
|
The DistanceEngine instance to visualize. |
required |
|
DistanceResult | None
|
Optional DistanceResult from plane_distance computation. |
None
|
|
Figure | None
|
Existing figure to add to, or None to create a new figure. |
None
|
|
bool
|
Whether to show axis start/end point markers. |
True
|
|
bool
|
Whether to show the curve points. |
True
|
|
bool
|
Whether to show the distance plane (requires distance_result). |
True
|
|
bool
|
Whether to show distance result points and vectors. |
True
|
|
bool
|
Whether to show projection lines (requires distance_result). |
True
|
|
float
|
Scale of the plane visualization. |
10.0
|
|
int
|
Grid density for plane mesh. |
3
|
|
Iterable[str] | None
|
Labels for axis start and end points. |
None
|
|
str
|
Color for axis line and points. |
'darkviolet'
|
|
str
|
Color for curve points. |
'darkblue'
|
|
str
|
Color for plane surface. |
'gold'
|
|
str
|
Color for projection vectors. |
'firebrick'
|
|
str | None
|
Optional string to append to legend groups for uniqueness. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
Plotly figure with all requested components. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If distance_engine is missing required attributes. |
ValueError
|
If show_distance_result is True but distance_result is None. |
Examples:
1 2 3 4 5 | |
Source code in src/mechaphlowers/plotting/plot_distances.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 | |
plot_text
Add text label to figure.
Args: text: DistanceResult containing distance_3d attribute for label text. fig: Plotly figure to add text to. title_addendum: String to append to legend group for uniqueness. position: 3D coordinates for text label placement.
Source code in src/mechaphlowers/plotting/plot_distances.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |