From c5f30af34889ec6ff59197f617ee9835bf537fac Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 26 Aug 2022 23:09:12 +0200 Subject: The example plot is a bit interactive now --- plot.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plot.py b/plot.py index 6ba676e..c691d0f 100644 --- a/plot.py +++ b/plot.py @@ -61,10 +61,17 @@ def find_boundary_curves(swis, x, y): swis = load("dataset") -x = 16.61 -y = 8600 -segments = find_boundary_curves(swis, x, y) -plot.plot([x], [y], "rx") -for index, data, i, j in segments: - plot.plot([x[0] for x in data], [x[1] for x in data], ".") + +def onclick(event): + if event.button != 1: + return + plot.clf() + segments = find_boundary_curves(swis, event.xdata, event.ydata) + plot.plot([event.xdata], [event.ydata], "rx") + for index, data, i, j in segments: + plot.plot([x[0] for x in data], [x[1] for x in data], ".", label=index) + plot.show() + +fig, _ = plot.subplots() +fig.canvas.mpl_connect('button_press_event', onclick) plot.show() -- cgit v1.1