pylinkage.visualizer package
Submodules
pylinkage.visualizer.animated module
The visualizer module makes visualization of linkages easy using matplotlib.
Created on Mon Jun 14, 12:13:58 2021.
@author: HugoFara
- pylinkage.visualizer.animated.plot_kinematic_linkage(linkage: Linkage, fig: Figure, axis: Axes, loci: Sequence[tuple[Coord, ...]], frames: int = 100, interval: float = 40) FuncAnimation
Plot a linkage with an animation.
- Args:
linkage: The linkage to animate. fig: Figure to support the axes. axis: The subplot to draw on. loci: list of list of coordinates. frames: Number of frames to draw the linkage on. interval: Delay between frames in milliseconds.
- Returns:
The animation object.
- pylinkage.visualizer.animated.show_linkage(linkage: Linkage, save: bool = False, prev: Sequence[Coord] | None = None, loci: Sequence[tuple[Coord, ...]] | None = None, points: int = 100, iteration_factor: float = 1, title: str | None = None, duration: float = 5, fps: int = 24) FuncAnimation
Display results as an animated drawing.
- Args:
linkage: The Linkage you want to draw. save: To save the animation. prev: Previous coordinates to use for linkage. loci: list of loci. points: Number of points to draw for a crank revolution.
Useless when loci are set.
- iteration_factor: A simple way to subdivide the movement. The real
number of points will be points * iteration_factor.
title: Figure title. Defaults to str(len(ani)). duration: Animation duration (in seconds). fps: Number of frames per second for the output video.
- Returns:
The animation object.
- pylinkage.visualizer.animated.swarm_tiled_repr(linkage: Linkage, swarm: tuple[int, Sequence[tuple[float, np.ndarray, Sequence[Coord]]]], fig: Figure, axes: np.ndarray, dimension_func: Callable[[np.ndarray], Sequence[float]] | None = None, points: int = 12, iteration_factor: float = 1) None
Show all the linkages in a swarm in tiled mode.
- Args:
linkage: The original Linkage that will be MODIFIED. swarm: Tuple of (iteration_number, list_of_agents) where each agent is
(score, dimensions, initial_positions).
fig: Figure to support the axes. axes: The subplot to draw on. points: Number of steps to use for each Linkage. iteration_factor: A simple way to subdivide the movement. The real
number of points will be points * iteration_factor.
- dimension_func: If you want a special formatting of dimensions from
agents before passing them to the linkage.
- pylinkage.visualizer.animated.update_animated_plot(linkage: Linkage, index: int, images: list[Line2D], loci: Sequence[tuple[Coord, ...]]) list[Line2D]
Modify im, instead of recreating it to make the animation run faster.
- Args:
linkage: The linkage being animated. index: Frame index. images: Artist to be modified. loci: list of loci.
- Returns:
Updated version of images.
pylinkage.visualizer.core module
Core features for visualization.
This module provides shared utilities for matplotlib-based visualization. For symbol definitions used by other backends (Plotly, drawsvg), see symbols.py.
pylinkage.visualizer.static module
Static (not animated) visualization.
- pylinkage.visualizer.static.plot_static_linkage(linkage: Linkage, axis: Axes, loci: Iterable[tuple[Coord, ...]], locus_highlights: list[list[Coord]] | None = None, show_legend: bool = False) None
Plot a linkage without movement.
- Args:
linkage: The linkage you want to see. axis: The graph we should draw on. loci: List of list of coordinates. They will be plotted. locus_highlights: If a list, should be a list of list of coordinates you
want to see highlighted.
show_legend: To add an automatic legend to the graph.
Module contents
Linkage visualization features.
- Backends:
matplotlib (default): plot_static_linkage, plot_kinematic_linkage, show_linkage
plotly: plot_linkage_plotly, animate_linkage_plotly (interactive HTML)
drawsvg: plot_linkage_svg, save_linkage_svg (publication-quality SVG)
dxf: plot_linkage_dxf, save_linkage_dxf (CAD/CNC export)
step: build_linkage_3d, save_linkage_step (3D CAD interchange)