def plot_mean_boxplot_with_pearson(dataset_id): data = [] pearson = [] for i, technique_id in enumerate(technique_list): print(Globals.acronyms[technique_id], end=' ', flush=True) technique_pearson = [] technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history) - 1): delta_vis = DeltaMetrics.compute_delta_vis(history[revision], history[revision + 1]) delta_data = DeltaMetrics.compute_delta_data( history[revision], history[revision + 1]) un_mov = UnavoidableMovement.compute_unavoidable_movement( history[revision], history[revision + 1]) ratios = (1 - delta_vis) / (1 - delta_data) diffs = 1 - abs(delta_vis - delta_data) unavoidable = 1 - (delta_vis - un_mov) mean = (ratios + diffs + unavoidable) / 3 technique_data.append(mean) # Compute linear regression statistics _, _, r_value, _, _ = stats.linregress(delta_data, delta_vis) technique_pearson.append(r_value if r_value > 0 else 0) data.append(technique_data) pearson.append(technique_pearson) TimeBoxplot.plot_with_pearson(data, technique_list, pearson, title='Mean with Pearson - ' + dataset_id)
def plot_time_boxplot(dataset_id): data = [] for i, technique_id in enumerate(technique_list): technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history) - 1): shneiderman = compute_shneiderman(history[revision], history[revision + 1]) technique_data.append(shneiderman) data.append(technique_data) TimeBoxplot.plot(data, technique_list, title="Shneiderman - " + dataset_id)
def plot_time_boxplot(dataset_id): data = [] for i, technique_id in enumerate(technique_list): technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history) - 1): rpc = relative_position_change_wrapper(history[revision], history[revision + 1]) technique_data.append(rpc) data.append(technique_data) print(Globals.acronyms[technique_id], end=' ', flush=True) TimeBoxplot.plot(data, technique_list, title="RPC - " + dataset_id)
def pearson_matrix(dataset_ids): matrix = [] for dataset_id in dataset_ids: dataset_values = [] for technique_id in technique_list: # print(Globals.acronyms[technique_id], dataset_id) history = Parser.parse_rectangles(technique_id, dataset_id) # Compute all delta_vis and delta_data values for a dataset (1 pair per cell) all_delta_data = np.array([]) all_delta_vis = np.array([]) for revision in range(len(history) - 1): delta_data = DeltaMetrics.compute_delta_data(history[revision], history[revision + 1]) all_delta_data = np.append(all_delta_data, delta_data) delta_vis = DeltaMetrics.compute_delta_vis(history[revision], history[revision + 1]) all_delta_vis = np.append(all_delta_vis, delta_vis) # Compute linear regression statistics slope, intercept, r_value, p_value, std_err = stats.linregress(all_delta_data, all_delta_vis) dataset_values.append(r_value) print(Globals.acronyms[technique_id], dataset_id, r_value) matrix.append(dataset_values) matrix = np.array(matrix).transpose() MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=True, title='Pearson') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=True, title='Pearson') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=False, title='Pearson') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=False, title='Pearson')
def plot_ar_matrix(dataset_ids): matrix = [] for dataset_id in dataset_ids: dataset_values = [] for technique_id in technique_list: history = Parser.parse_rectangles(technique_id, dataset_id) all_ratios = np.array([]) for revision in range(len(history) - 1): ratios = compute_aspect_ratios(history[revision]) all_ratios = np.append(all_ratios, ratios.values) dataset_values.append(all_ratios.mean()) print(Globals.acronyms[technique_id], dataset_id, all_ratios.mean()) matrix.append(dataset_values) matrix = np.array(matrix).transpose() MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=True, title='Aspect ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=True, title='Aspect ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=False, title='Aspect ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=False, title='Aspect ratio')
def plot_matrix(dataset_ids): matrix = [] for dataset_id in dataset_ids: dataset_values = [] for technique_id in technique_list: history = Parser.parse_rectangles(technique_id, dataset_id) avg = compute_location_drift(history) dataset_values.append(avg) print(Globals.acronyms[technique_id], dataset_id, avg) matrix.append(dataset_values) matrix = np.array(matrix).transpose() MatrixPlot.plot(matrix, dataset_ids, technique_list, cell_text=True, title='Location Drift')
def delta_ratio_boxplots(dataset_id): data = [] for i, technique_id in enumerate(technique_list): technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history) - 1): delta_vis = compute_delta_vis(history[revision], history[revision + 1]) delta_data = compute_delta_data(history[revision], history[revision + 1]) ratios = (1 - delta_vis) / (1 - delta_data) technique_data.append(ratios) data.append(technique_data) TimeBoxplot.plot(data, technique_list, title="Delta Ratio - " + dataset_id) TimeBoxplot.plot(data, technique_list, median_sorted=True, title="Delta Ratio - " + dataset_id)
def plot_time_boxplot(dataset_id): data = [] for i, technique_id in enumerate(technique_list): technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history)): ratios = compute_aspect_ratios(history[revision]).tolist() technique_data.append(ratios) data.append(technique_data) TimeBoxplot.plot(data, technique_list, title="Aspect Ratios - " + dataset_id) TimeBoxplot.plot(data, technique_list, median_sorted=True, title="Aspect Ratios - " + dataset_id)
def plot_mean_boxplot( dataset_id, metrics='VIS'): # Default case was what was used at VIS18 paper data = [] for i, technique_id in enumerate(technique_list): print(Globals.acronyms[technique_id], end=' ', flush=True) technique_data = [] history = Parser.parse_rectangles(technique_id, dataset_id) for revision in range(len(history) - 1): if metrics == 'VIS': delta_vis = DeltaMetrics.compute_delta_vis( history[revision], history[revision + 1]) delta_data = DeltaMetrics.compute_delta_data( history[revision], history[revision + 1]) un_mov = UnavoidableMovement.compute_unavoidable_movement( history[revision], history[revision + 1]) ratios = (1 - delta_vis) / (1 - delta_data) diffs = 1 - abs(delta_vis - delta_data) unavoidable = 1 - (delta_vis - un_mov) mean = (ratios + diffs + unavoidable) / 3 elif metrics == 'SIBGRAPI': delta_vis = DeltaMetrics.compute_delta_vis( history[revision], history[revision + 1]) delta_data = DeltaMetrics.compute_delta_data( history[revision], history[revision + 1]) ratios = (1 - delta_vis) / (1 - delta_data) shn = ShneidermanWattenberg.compute_shneiderman( history[revision], history[revision + 1]) mean = (ratios + shn) / 2 technique_data.append(mean) data.append(technique_data) TimeBoxplot.plot(data, technique_list, title='Mean - ' + dataset_id) TimeBoxplot.plot(data, technique_list, median_sorted=True, title='Mean - ' + dataset_id)
def plot(dataset_id): fig, axs = plt.subplots(math.ceil(len(technique_list) / 5), 5) fig.suptitle("Centroid Trail - " + dataset_id) norm = math.sqrt( 1000**2 + 1000** 2) # Assuming we are plotting the treemap in a 1000x1000 pixel frame for i, technique_id in enumerate(technique_list): ax = fig.axes[i] ax.set_title(Globals.acronyms[technique_id]) history = Parser.parse_rectangles(technique_id, dataset_id) centroids = compute_centroids(history) lines = [] colors = [] for key, centroid_list in centroids.items(): for i in range(len(centroid_list) - 1): a = centroid_list[i] b = centroid_list[i + 1] lines.append((a, b)) # Add line segment alpha = math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2) / norm alpha = alpha / math.sqrt(len(centroid_list)) colors.append((0, 0, 0, alpha)) # Set color for line segment lc = mc.LineCollection(lines, colors=colors, linewidths=1) ax.add_collection(lc) ax.set_xlim(0, 1000) ax.set_ylim(0, 1000) ax.tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False) ax.tick_params(axis='y', which='both', left=False, right=False, labelleft=False) ax.set_aspect('equal', adjustable='box') fig.savefig(Globals.plot_subdir + dataset_id + '.png', dpi=500)
def delta_ratio_matrix(dataset_ids): matrix = [] for dataset_id in dataset_ids: dataset_values = [] for technique_id in technique_list: history = Parser.parse_rectangles(technique_id, dataset_id) all_ratios = np.array([]) for revision in range(len(history) - 1): delta_vis = compute_delta_vis(history[revision], history[revision + 1]) delta_data = compute_delta_data(history[revision], history[revision + 1]) ratio = (1 - delta_vis) / (1 - delta_data) all_ratios = np.append(all_ratios, ratio.values) dataset_values.append(all_ratios.mean()) print(Globals.acronyms[technique_id], dataset_id, all_ratios.mean()) matrix.append(dataset_values) matrix = np.array(matrix).transpose() MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=True, title='Delta ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=True, title='Delta ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=False, cell_text=False, title='Delta ratio') MatrixPlot.plot(matrix, dataset_ids, technique_list, shared_cm=True, cell_text=False, title='Delta ratio')
def plot_matrix(dataset_ids): matrix = [] for dataset_id in dataset_ids: dataset_values = [] for technique_id in technique_list: history = Parser.parse_rectangles(technique_id, dataset_id) all_ratios = np.array([]) for revision in range(len(history) - 1): distances = compute_shneiderman(history[revision], history[revision + 1]) all_ratios = np.append(all_ratios, distances.values) dataset_values.append(all_ratios.mean()) print(Globals.acronyms[technique_id], dataset_id, all_ratios.mean()) matrix.append(dataset_values) matrix = np.array(matrix).transpose() MatrixPlot.plot(matrix, dataset_ids, technique_list, cell_text=True, title='Shneiderman-Wattenberg')
def scatter(dataset_id): fig, axs = plt.subplots(int(len(technique_list)/2), 2, sharex=True, sharey=True, figsize=(20, 44)) xlim = 0 for i, technique_id in enumerate(technique_list): # print(Globals.acronyms[technique_id]) ax = fig.axes[i] history = Parser.parse_rectangles(technique_id, dataset_id) # Compute all delta_vis and delta_data values for a dataset (1 pair per cell) all_delta_data = np.array([]) all_delta_vis = np.array([]) for revision in range(len(history) - 1): delta_data = DeltaMetrics.compute_delta_data(history[revision], history[revision + 1]) all_delta_data = np.append(all_delta_data, delta_data) delta_vis = DeltaMetrics.compute_delta_vis(history[revision], history[revision + 1]) all_delta_vis = np.append(all_delta_vis, delta_vis) # Compute linear regression and draw regression line slope, intercept, r_value, p_value, std_err = stats.linregress(all_delta_data, all_delta_vis) if xlim == 0: xlim = np.percentile(all_delta_data, 99.99) # Remove outliers # If there are too many points to handle, first we draw all of them in black (alpha), # then subsample the space, perform kde, and draw the colored subsample # over the original points sample_size = 10000 if len(all_delta_data) > sample_size: ax.scatter(all_delta_data, all_delta_vis, color='k', s=1, alpha=.25) # matrix = df[['delta_data', 'delta_vis']].sample(sample_size).T.as_matrix() indices = np.random.choice(len(all_delta_vis), sample_size) matrix = np.vstack([all_delta_data[indices], all_delta_vis[indices]]) dens = stats.gaussian_kde(matrix) dens_pt = dens(matrix) colours = make_colors(dens_pt, 'inferno') ax.scatter(matrix[0], matrix[1], color=colours, s=3, alpha=.05) else: matrix = np.vstack([all_delta_data, all_delta_vis]) dens = stats.gaussian_kde(matrix) dens_pt = dens(matrix) colours = make_colors(dens_pt, 'inferno') ax.scatter(matrix[0], matrix[1], color=colours, s=3, alpha=.25) line = np.poly1d([slope, intercept])(all_delta_data) ax.plot(all_delta_data, line, 'r-', lw=.5) print(Globals.acronyms[technique_id], r_value) title = Globals.acronyms[technique_id] title += r" $\alpha = $" + "{0:.2f}".format(intercept) title += r" $\beta = $" + "{0:.2f}".format(slope) title += r" $r = $" + "{0:.3f}".format(r_value) title += r" $s_e = $" + "{0:.3f}".format(std_err) ax.set_title(title) ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) ax.tick_params(axis='x', which='both', top='off') ax.tick_params(axis='y', which='both', right='off') ax.set_xlim(xmin=0, xmax=xlim) ax.set_ylim(ymin=0) fig.savefig(Globals.plot_subdir + 'scatter-' + dataset_id + '.png', dpi=500) # plt.show() return