motornet.utils.plotor#
This module contains various functions for plotting data from MotorNet training and simulation sessions.
- motornet_tf.utils.plotor.animate_trajectory(joint_position, model, save_animation=False, path_name='./Arm_animation.mp4')#
- motornet_tf.utils.plotor.compute_limits(data, margin=0.1)#
Computes the limits to use for plotting data, given the range of the dataset and a margin size around that range.
- Parameters:
data – A numpy.ndarray containing the data to plot.
margin – Float, the proportion of the data’s range to add as margin for plotting. For instance, if the data value range from 0 to 10, and the margin is set to 0.2, then the limits would become [-2, 12] since the range is 10.
- Returns:
A list of two float values, representing the lower and upper limits to use on the plot, in that order.
- motornet_tf.utils.plotor.plot_2dof_arm_over_time(axis, arm, joint_state, cmap: str = 'viridis', linewidth: int = 1)#
Plots an arm26 over time, with earlier and later arm configuration in the movement being represented as darker and brighter colors, respectively.
- Parameters:
axis – A matplotlib axis handle.
arm –
motornet.plants.skeletons.TwoDofArm
object to plot.joint_state – A numpy.ndarray containing the trajectory. Its dimensionality should be 1 * n_timesteps * (2 . n_dim), with n_dim being the trajectory’s dimensionality. For an arm26, since the arm has 2 degrees of freedom, we have`n_dim = 2`, meaning the third dimension of the array is 4 (shoulder position, elbow position, shoulder velocity, elbow velocity).
cmap – String, colormap supported by matplotlib.
linewidth – Integer, line width of the arm segments being plotted.
- motornet_tf.utils.plotor.plot_pos_over_time(cart_results, axis, cmap='viridis')#
Plots trajectory position over time, giving a darker color to the early part of a trajectory, and a lighter color to the later part of the trajectory.
- Parameters:
axis – A matplotlib axis handle to plot the trajectories.
cart_results – A numpy.ndarray containing the trajectories. Its dimensionality should be n_batches * n_timesteps * (2 . n_dim), with n_dim being the trajectory’s dimensionality. For instance, for a planar reach, since the movement is in 2D space, we have`n_dim = 2`, meaning the third dimension of the array is 4 (x position, y position, x velocity, y velocity).
cmap – String or matplotlib colormap object, the colormap to use to visualize positions over time.