diff --git a/extract_data_absolute.py b/extract_data_absolute.py index a33af0b..5e24ac1 100644 --- a/extract_data_absolute.py +++ b/extract_data_absolute.py @@ -113,12 +113,28 @@ class DiagramExtractor: # Extract edges in plot region plot_edges = edges[plot_top:plot_bottom, plot_left:plot_right] - - # Remove axes from edges - plot_edges[0:5, :] = 0 - plot_edges[-5:, :] = 0 - plot_edges[:, 0:5] = 0 - plot_edges[:, -5:] = 0 + + # Remove borders and axis lines to avoid captions/ticks + border_margin = 12 + axis_band = 6 + + plot_edges[0:border_margin, :] = 0 + plot_edges[-border_margin:, :] = 0 + plot_edges[:, 0:border_margin] = 0 + plot_edges[:, -border_margin:] = 0 + + x_axis_rel = x_axis_y - plot_top + y_axis_rel = y_axis_x - plot_left + + if 0 <= x_axis_rel < plot_edges.shape[0]: + start = max(0, x_axis_rel - axis_band) + end = min(plot_edges.shape[0], x_axis_rel + axis_band + 1) + plot_edges[start:end, :] = 0 + + if 0 <= y_axis_rel < plot_edges.shape[1]: + start = max(0, y_axis_rel - axis_band) + end = min(plot_edges.shape[1], y_axis_rel + axis_band + 1) + plot_edges[:, start:end] = 0 # Find coordinates of edges (curve points) curve_coords = np.where(plot_edges > 0)