visualizer

Simple plotter for your linkages

The visualizer module makes visualization of linkages easy using matplotlib.

Created on Mon Jun 14, 12:13:58 2021.

@author: HugoFara

pylinkage.visualizer._get_color(joint)

Search in COLOR_SWITCHER for the corresponding color.

Parameters:

joint

pylinkage.visualizer.plot_kinematic_linkage(linkage, fig, axis, loci, frames=100, interval=40)

Plot a linkage with an animation.

Parameters:
  • linkage (pylinkage.linkage.Linkage) – DESCRIPTION.

  • fig (matplotlib.figure.Figure) – Figure to support the axes.

  • axis (matplotlib.axes._subplots.AxesSubplot) – The subplot to draw on.

  • loci (list) – list of list of coordinates.

  • frames (int) – Number of frames to draw the linkage on. The default is 100.

  • interval (float) – Delay between frames in milliseconds. The default is 40 (24 fps).

pylinkage.visualizer.plot_static_linkage(linkage, axis, loci, locus_highlights=None, show_legend=False)

Plot a linkage without movement.

Parameters:
  • linkage (Linkage) – The linkage you want to see.

  • axis (Artist) – The graph we should draw on.

  • loci (Iterable) – List of list of coordinates. They will be plotted.

  • locus_highlights (list) – If a list, should be a list of list of coordinates you want to see highlighted. The default is None.

  • show_legend (bool) – To add an automatic legend to the graph. The default is False.

pylinkage.visualizer.show_linkage(linkage, save=False, prev=None, loci=None, points=100, iteration_factor=1, title='0', duration=5, fps=24)

Display results as an animated drawing.

Parameters:
  • linkage (pylinkage.linkage.Linkage) – The Linkage you want to draw.

  • save (bool) – To save the animation. The default is False.

  • prev (list) – Previous coordinates to use for linkage. The default is None.

  • loci (list) – list of loci. The default is None.

  • points (int) – Number of points to draw for a crank revolution. Useless when loci are set. The default is 100.

  • iteration_factor (float) – A simple way to subdivide the movement. The real number of points will be points * iteration_factor. The default is 1.

  • title (str) – Figure title. The default is str(len(ani)).

  • duration (float) – Animation duration (in seconds). The default is 5.

  • fps (int) – Number of frames per second for the output video. The default is 24.

pylinkage.visualizer.swarm_tiled_repr(linkage, swarm, fig, axes, dimension_func=None, points=12, iteration_factor=1)

Show all the linkages in a swarm in tiled mode.

Parameters:
  • linkage (pylinkage.linkage.Linkage) – The original Linkage that will be MODIFIED.

  • swarm (list) – Sequence of list of 3 elements: for each iteration, for each agent, (score, dimensions and initial positions).

  • fig (matplotlib.figure.Figure) – Figure to support the axes.

  • axes (matplotlib.axes._subplots.AxesSubplot) – The subplot to draw on.

  • points (int) – Number of steps to use for each Linkage. The default is 12.

  • iteration_factor (float) – A simple way to subdivide the movement. The real number of points will be points * iteration_factor. The default is 1.

  • dimension_func (callable, optional) – If you want a special formatting of dimensions from agents before passing them to the linkage. (Default value = None)

pylinkage.visualizer.update_animated_plot(linkage, index, images, loci)

Modify im, instead of recreating it to make the animation run faster.

Parameters:
  • linkage (TYPE) – DESCRIPTION.

  • index (int) – Frame index.

  • images (list of images Artists) – Artist to be modified.

  • loci (list) – list of loci.

Returns:

Updated version

Return type:

list[Artists]