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_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_biplane_vicon(self, title: str, fig_num: int, vicon_field: str, vicon_type: str) \ -> matplotlib.figure.Figure: """Plot overlayed marker position data as measured via Vicon and biplane fluoroscopy.""" fig = plt.figure(num=fig_num) ax = fig.subplots(3, 1, sharex=True) lines_vicon = marker_graph_init(ax, getattr(self, vicon_field), 'Distance (mm)', self.vicon_frames, color='limegreen', marker='.', lw=1, ms=2) lines_biplane = marker_graph_add(ax, self.biplane_data, self.vicon_frames, color='indigo', marker='.') fig.legend((lines_biplane[0], lines_vicon[0]), ('Biplane', vicon_type + ' Vicon'), 'upper right', ncol=3, columnspacing=0.3, handlelength=1.0) marker_graph_title(fig, title) 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