def plot_pos_data(self, title: str, y_label: str, kine_var: str, fig_num: int, add_sd: bool = True, clip_graph: bool = False) -> matplotlib.figure.Figure: """Plot overlayed raw, filled, and smoothed marker position data.""" fig = plt.figure(num=fig_num) ax = fig.subplots(3, 1, sharex=True) lines_filled = marker_graph_init(ax, self.filled.means.pos, y_label, x_data=self.frames, color='red') lines_raw = marker_graph_add(ax, self.raw.means.pos, self.frames, color='indigo', marker='.') lines_smoothed = marker_graph_add(ax, getattr(self.smoothed.means, kine_var), self.filtered_frames, color='limegreen', lw=1) if add_sd: marker_graph_add_cov(ax, self.smoothed.means.pos, self.smoothed.covars.pos, self.filtered_frames, 'limegreen') if clip_graph: for c_ax in ax: c_ax.set_xlim(self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) else: add_vicon_start_stop(ax, self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) plt.tight_layout(pad=1.0, w_pad=1.0, h_pad=0) fig.suptitle(title, x=0.25, fontsize=11, fontweight='bold') plt.subplots_adjust(top=0.94) fig.legend((lines_raw[0], lines_filled[0], lines_smoothed[0]), ('Raw', 'Filled', 'Smoothed'), 'upper right', labelspacing=0.1, ncol=3, columnspacing=0.3) make_interactive() return fig
def plot_marker_data(self, title: str, y_label: str, kine_var: str, fig_num: int, add_sd: bool = True, clip_graph: bool = False, marker: str = '') -> matplotlib.figure.Figure: """Plot raw, filtered, and smoothed kinematic (position, velocity, acceleration) marker data, allowing the addition of confidence bounds.""" fig = plt.figure(num=fig_num) ax = fig.subplots(3, 1, sharex=True) lines_raw = marker_graph_init(ax, getattr(self.raw.means, kine_var), y_label, x_data=self.frames, color='indigo', marker=marker) lines_filtered = marker_graph_add(ax, getattr(self.filtered.means, kine_var), self.filtered_frames, color='red') lines_smoothed = marker_graph_add(ax, getattr(self.smoothed.means, kine_var), self.filtered_frames, color='limegreen') if add_sd: marker_graph_add_cov(ax, getattr(self.filtered.means, kine_var), getattr(self.filtered.covars, kine_var), self.filtered_frames, 'red') marker_graph_add_cov(ax, getattr(self.smoothed.means, kine_var), getattr(self.smoothed.covars, kine_var), self.filtered_frames, 'limegreen') if clip_graph: for c_ax in ax: c_ax.set_xlim(self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) else: add_vicon_start_stop(ax, self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) fig.legend((lines_raw[0], lines_filtered[0], lines_smoothed[0]), ('Raw', 'Filtered', 'Smoothed'), 'upper right', labelspacing=0.1) marker_graph_title(fig, title) make_interactive() return fig
def plot(self) -> List[matplotlib.figure.Figure]: """Plot marker_data onto 3 row subplots on Figure 0.""" fig = plt.figure(num=0) ax = fig.subplots(3, 1, sharex=True) marker_graph_init(ax, self.marker_pos_labeled, 'Pos (mm)', x_data=self.frame_nums, color='blue') add_vicon_start_stop(ax, self.vicon_endpts[0] + 1, self.vicon_endpts[1]) marker_graph_title(fig, self.trial_name + ' ' + self.marker_name) make_interactive() return [fig]
def plot_marker_data_diff(self, title: str, y_label: str, fig_num: int) -> matplotlib.figure.Figure: """Plot smoothed marker positions - raw marker positions.""" fig = plt.figure(num=fig_num) ax = fig.subplots(3, 1, sharex=True) lines_smoothed = marker_graph_init(ax, self.smoothed_pos_diff, y_label, x_data=self.filtered_frames, color='limegreen') fig.legend([lines_smoothed[0]], ['Smoothed'], 'upper right', labelspacing=0.1) add_vicon_start_stop(ax, self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) marker_graph_title(fig, title) make_interactive() return fig
def plot_marker_data_smooth(self, title: str, y_label: str, kine_var: str, fig_num: int) \ -> matplotlib.figure.Figure: """Plot smoothed kinematic (position, velocity, acceleration) marker data.""" fig = plt.figure(num=fig_num) ax = fig.subplots(3, 1, sharex=True) lines_smoothed = marker_graph_init(ax, getattr(self.smoothed.means, kine_var), y_label, x_data=self.filtered_frames, color='limegreen') fig.legend([lines_smoothed[0]], ['Smoothed'], 'upper right', labelspacing=0.1) add_vicon_start_stop(ax, self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) marker_graph_title(fig, title) make_interactive() return fig
def plot_cov(self, title: str, y_labels: Sequence[str], fig_num: int) -> matplotlib.figure.Figure: """Plot overlayed variance of filtered and smoothed kinematic variables (position, velocity, acceleration) in separate rows with 3 columns for each spatial dimension (3x3). """ fig = plt.figure(num=fig_num) ax = fig.subplots(3, 3, sharex='all', sharey='row') lines_filtered = cov_trend_graph_init(ax, self.filtered.covars, self.filtered_frames, y_labels, np.sqrt, color='red') lines_smooth = cov_trend_graph_add(ax, self.smoothed.covars, self.filtered_frames, np.sqrt, color='limegreen') fig.legend((lines_filtered[0][0], lines_smooth[0][0]), ('Filtered', 'Smoothed'), 'upper right', labelspacing=0.1, ncol=2) add_vicon_start_stop(ax, self.vicon_frame_endpts[0], self.vicon_frame_endpts[1]) marker_graph_title(fig, title) make_interactive() return fig