def make_histogram_set(assigned_attributes, channel_names, split, attribute_name, use_subplots=True): colors = [ display_pyutils.GOOD_COLOR_CYCLE[np.mod( i, len(display_pyutils.GOOD_COLOR_CYCLE))] for i in range(len(channel_names)) ] labels = channel_names density, global_bins, patches = display_pyutils.histogram( assigned_attributes, bins=None, color=colors, label=labels, histtype='stepfilled') plt.figure(figsize=FIGSIZE) plt.clf() if use_subplots: R = len(channel_names) plt.subplot(R, 1, 1) axes_list = [] labels = [ '{} ({} instances)'.format(channel_names[channel_idx], len(assigned_attributes[channel_idx])) for channel_idx in range(len(channel_names)) ] for subplot_idx, channel_idx in enumerate(range(len(channel_names))): ax = plt.subplot(R, 1, subplot_idx + 1) axes_list.append(ax) y = assigned_attributes[channel_idx] channel_name = channel_names[channel_idx] bins = np.linspace(global_bins[0], global_bins[-1], 100) label = labels[subplot_idx] density, bins, patches = display_pyutils.histogram( y, bins=bins, color=colors[subplot_idx], label=label, histtype='stepfilled') # plt.legend(patches, labels, loc='center left', fontsize=8, bbox_to_anchor=(-0.02, 0.5)) if subplot_idx == 0: title = '{}: {}'.format(split, attribute_name) plt.title(title, fontsize=16) # plt.legend(loc='center left', fontsize=8, bbox_to_anchor=(-0.02, 0.5)) plt.xlabel('{} for assigned ground truth instances'.format( attribute_name), fontsize=12) plt.legend(loc='upper right', fontsize=16) display_pyutils.sync_axes(axes_list, axis='x') display_pyutils.sync_axes(axes_list, axis='y') else: bins = None density, bins, patches = display_pyutils.histogram(assigned_attributes, bins=None, color=colors, label=labels, histtype='bar') title = '{}: {}'.format(split, attribute_name) plt.xlabel( '{} for assigned ground truth instances'.format(attribute_name), fontsize=12) plt.title(title, fontsize=16) plt.legend(loc='upper right', fontsize=16) plt.tight_layout(pad=1.2) filename = '{}_{}_distributions_{}.png'.format( split, attribute_name, 'subplots' if use_subplots else 'combined') display_pyutils.save_fig_to_workspace(filename)
def make_scatterplot3d_set(xs, ys, zs, channel_names, split, x_attribute_name, y_attribute_name, z_attribute_name, use_subplots=True): colors = [ display_pyutils.GOOD_COLOR_CYCLE[np.mod( i, len(display_pyutils.GOOD_COLOR_CYCLE))] for i in range(len(channel_names)) ] labels = channel_names plt.figure(figsize=FIGSIZE) plt.clf() if use_subplots: R = len(channel_names) plt.subplot(R, 1, 1) axes_list = [] labels = [ '{} ({} instances)'.format(channel_names[channel_idx], len(ys[channel_idx])) for channel_idx in range(len(channel_names)) ] for subplot_idx, channel_idx in enumerate(range(len(channel_names))): ax = plt.subplot(R, 1, subplot_idx + 1) axes_list.append(ax) channel_name = channel_names[channel_idx] label = labels[subplot_idx] x = xs[channel_idx] y = ys[channel_idx] z = zs[channel_idx] display_pyutils.scatter3(x, y, z, zdir='z', label=label, color=colors[subplot_idx]) # plt.legend(patches, labels, loc='center left', fontsize=8, bbox_to_anchor=(-0.02, 0.5)) if subplot_idx == 0: title = '{}: {} vs. {}'.format(split, x_attribute_name, y_attribute_name) plt.title(title, fontsize=16) # plt.legend(loc='center left', fontsize=8, bbox_to_anchor=(-0.02, 0.5)) plt.xlabel('{} for assigned ground truth instances'.format( x_attribute_name), fontsize=12) plt.ylabel('{}'.format(y_attribute_name), fontsize=12) plt.legend(loc='upper right', fontsize=16) display_pyutils.sync_axes(axes_list, axis='x') display_pyutils.sync_axes(axes_list, axis='y') else: plt.hold(True) for channel_idx in range(len(channel_names)): label = labels[channel_idx] x = xs[channel_idx] y = ys[channel_idx] z = zs[channel_idx] display_pyutils.scatter3(x, y, z, zdir='z', label=label, color=colors[channel_idx]) plt.scatter(x, y, label=label, color=colors[channel_idx]) title = '{}: {} vs. {}'.format(split, x_attribute_name, y_attribute_name) plt.xlabel( '{} for assigned ground truth instances'.format(x_attribute_name), fontsize=12) plt.ylabel('{}'.format(y_attribute_name), fontsize=12) plt.title(title, fontsize=16) plt.legend(loc='upper right', fontsize=16) plt.tight_layout(pad=1.2) filename = '{}_scatter3_x_{}_y_{}_z_{}_{}.png'.format( split, x_attribute_name, y_attribute_name, z_attribute_name, 'subplots' if use_subplots else 'combined') display_pyutils.save_fig_to_workspace(filename)