def plot_marker_cluster_avail(ax: matplotlib.axes.Axes, marker_data: np.ndarray, frame_nums: np.ndarray, marker_names: Collection[str], vicon_endpts: np.ndarray, **kwargs) \ -> Tuple[List[matplotlib.lines.Line2D], List[matplotlib.lines.Line2D]]: """Create plot showing the presence of each marker in a marker cluster.""" marker_ints = np.arange(len(marker_names)) markers_present = ~np.any(np.isnan(marker_data), 2) lines_present = [] lines_absent = [] for i in marker_ints: marker_present = markers_present[i] line_present = ax.plot(frame_nums[marker_present], np.ones(np.count_nonzero(marker_present)) * (i+1), 'gs', ms=6, ls='', **kwargs) line_absent = ax.plot(frame_nums[~marker_present], np.ones(np.count_nonzero(~marker_present)) * (i + 1), 'rs', ms=6, ls='', **kwargs) lines_present.append(line_present[0]) lines_absent.append(line_absent[0]) ax.set_yticks(marker_ints + 1) ax.set_yticklabels(marker_names) plot_utils.update_spines(ax) plot_utils.update_xticks(ax, font_size=8) plot_utils.update_yticks(ax, fontsize=8) plot_utils.update_xlabel(ax, 'Frame Number', font_size=10) ax.axvline(vicon_endpts[0] + 1) ax.axvline(vicon_endpts[1]) return lines_present, lines_absent
def marker_diff_his_init(ax: np.ndarray, filtered_diff: np.ndarray, x_label: str, color: str) \ -> List[matplotlib.patches.Polygon]: """Histogram plot each column of filtered_diff ((n,3) numpy array) onto the axes provided in ax. Additionally, visually format each Axes and include a x_label on 2nd Axes. """ polygons_filtered = [] for n in range(3): current_filtered_diff = filtered_diff[:, n] _, _, patches_filtered = ax[n].hist( current_filtered_diff[~np.isnan(current_filtered_diff)], bins=20, histtype='step', color=color) polygons_filtered.append(patches_filtered[0]) plot_utils.update_spines(ax[n]) plot_utils.update_xticks(ax[n], font_size=8) plot_utils.update_yticks(ax[n], fontsize=8) if n == 1: plot_utils.update_xlabel(ax[n], x_label, font_size=10) elif n == 0: plot_utils.update_ylabel(ax[n], 'Instances', font_size=10) return polygons_filtered
def update_bp_xticks(ax, num_bars, tick_labels, font_size=12, font_weight='bold'): ax.set_xticks(np.arange(num_bars)) ax.set_xticklabels(tick_labels) plot_utils.update_xticks(ax, font_size=font_size, font_weight=font_weight) ax.xaxis.set_tick_params(which='both', length=0)
def update_bp_xticks_groups(ax, num_bars, num_groups, num_metrics, tick_labels, font_size=12, font_weight='bold'): first_tick = np.average(np.arange(num_metrics) + 1) ax.set_xticks(np.arange(first_tick, num_bars + num_groups, num_metrics + 1)) ax.set_xticklabels(tick_labels) plot_utils.update_xticks(ax, font_size=font_size, font_weight=font_weight) ax.xaxis.set_tick_params(which='both', length=0)
def marker_diff_graph(ax: matplotlib.axes.Axes, marker_data: np.ndarray, y_label: str, x_label: Union[str, None], x_data: np.ndarray, **kwargs) -> matplotlib.lines.Line2D: """Plot marker_data onto the axes provided in ax. Additionally, visually format the axes and include a y_label. **kwargs passed to matplotlib plot(). """ lines = ax.plot(x_data, marker_data, **kwargs) plot_utils.update_spines(ax) plot_utils.update_xticks(ax, font_size=8) plot_utils.update_yticks(ax, fontsize=8) if x_label: plot_utils.update_xlabel(ax, x_label, font_size=10) plot_utils.update_ylabel(ax, y_label, font_size=10) return lines
def kine_graph_init(ax: matplotlib.axes.Axes, marker_data: np.ndarray, y_label: str, x_data: np.ndarray, plot_args=None) -> List[matplotlib.lines.Line2D]: """Plot each column of marker_data ((n,3) numpy array) onto the axes provided in ax. Additionally, visually format each Axes and include a y_label on 2nd Axes. **kwargs passed to matplotlib plot(). """ if plot_args is None: plot_args = [{}] * marker_data.shape[1] lines = [] for dim in range(marker_data.shape[1]): current_line, = ax.plot(x_data, marker_data[:, dim], **plot_args[dim]) lines.append(current_line) plot_utils.update_spines(ax) plot_utils.update_xticks(ax, font_size=8) plot_utils.update_yticks(ax, fontsize=8) ax.margins(x=0, y=0.05) ax.yaxis.set_major_locator(ticker.MaxNLocator(nbins=4, integer=True)) plot_utils.update_xlabel(ax, 'Frame Number', font_size=10) plot_utils.update_ylabel(ax, y_label, font_size=10) return lines
def marker_graph_init(ax: np.ndarray, marker_data: np.ndarray, y_label: str, x_data: np.ndarray, **kwargs) \ -> List[matplotlib.lines.Line2D]: """Plot each column of marker_data ((n,3) numpy array) onto the axes provided in ax. Additionally, visually format each Axes and include a y_label on 2nd Axes. **kwargs passed to matplotlib plot(). """ lines = [] for n in range(3): current_line, = ax[n].plot(x_data, marker_data[:, n], **kwargs) lines.append(current_line) plot_utils.update_spines(ax[n]) plot_utils.update_xticks(ax[n], font_size=8) plot_utils.update_yticks(ax[n], fontsize=8) ax[n].margins(x=0, y=0.05) ax[n].yaxis.set_major_locator(ticker.MaxNLocator(nbins=4, integer=True)) if n == 2: plot_utils.update_xlabel(ax[n], 'Frame Number', font_size=10) elif n == 1: plot_utils.update_ylabel(ax[n], y_label, font_size=10) return lines
def cov_trend_graph_init(ax: np.ndarray, variance_data: Any, x_data: np.ndarray, y_labels: Sequence[str], process_func: Callable, **kwargs) -> List[List[matplotlib.lines.Line2D]]: """Plot each kinematic variable/dimension combination contained in variance_data (tuple of 3 kinematic variables, each comprised of a (n, 3) numpy array) onto the 3 rows (kinematic variable) and 3 columns (dimension) contained in ax. Apply process_func to each kinematic variable/dimension before plotting. Additionally, visually format each axes and include a y_label for the first column of each row. **kwargs passed to matplotlib plot(). """ lines = [] # iterate over kinematic variable for i in range(3): # iterate over dimension dim_lines = [] for j in range(3): line, = ax[i, j].plot(x_data, process_func(variance_data[i][:, j]), **kwargs) dim_lines.append(line) plot_utils.update_spines(ax[i, j]) plot_utils.update_xticks(ax[i, j], font_size=8) plot_utils.update_yticks(ax[i, j], fontsize=8) ax[i, j].margins(x=0, y=0.05) ax[i, j].yaxis.set_major_locator( ticker.MaxNLocator(nbins=4, integer=True)) if i == 2 and j == 1: plot_utils.update_xlabel(ax[i, j], 'Frame Number', font_size=10) if j == 0: plot_utils.update_ylabel(ax[i, j], y_labels[i], font_size=10) lines.append(dim_lines) return lines