diff options
author | Aki <please@ignore.pl> | 2022-08-26 23:09:12 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-08-26 23:09:12 +0200 |
commit | c5f30af34889ec6ff59197f617ee9835bf537fac (patch) | |
tree | 66e173de1fd7f1f0459b33f829120a02e572561b | |
parent | beb3b7582ee8ceb0ea8af3e1747dbce2bf60bfb0 (diff) | |
download | szilagyi-c5f30af34889ec6ff59197f617ee9835bf537fac.zip szilagyi-c5f30af34889ec6ff59197f617ee9835bf537fac.tar.gz szilagyi-c5f30af34889ec6ff59197f617ee9835bf537fac.tar.bz2 |
The example plot is a bit interactive now
-rw-r--r-- | plot.py | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -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() |