visualizer

Simple plotter for your linkages

The visualizer module makes visualisation 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.

pylinkage.visualizer.movement_bounding_bow(loci)

Return the general bounding box of a group of loci.

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, optional) – Number of frames to draw the linkage on. The default is 100.

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

Returns

Return type

None.

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 (sequence) – List of list of coordinates. They will be plotted.

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

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

Returns

Return type

None.

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, optional) – To save the animation. The default is False.

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

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

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

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

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

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

  • fps (float, optional) – Number of frame per second for the output video. The default is 24.

Returns

Return type

None.

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 3 elements: agents, interation number and initial positions.

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

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

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

  • iteration_factor (float, optional) – 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.

Returns

Return type

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 locuses.

Returns

im – Updated version.

Return type

list of images Artists