Skip to content

Commit 59088f4

Browse files
committed
Add scatter label option for cursor
1 parent 7c5ae38 commit 59088f4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

example_cursor_scatter_experimental/graph_widget.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def __init__(self, **kwargs):
9090

9191
self.lines=[]
9292
self.scatters=[]
93+
self.scatter_label = None
9394

9495
self.bind(size=self._onSize)
9596

@@ -314,7 +315,10 @@ def hover(self, event) -> None:
314315
self.vertical_line.set_xdata(x)
315316

316317
#x y label
317-
self.text.set_text(f"x={x}, y={y}")
318+
if self.scatter_label and idx_best > len(good_line)-1:
319+
self.text.set_text(f"pt{self.scatter_label [good_index_scatter[idx_best]]} x={x}, y={y}")
320+
else:
321+
self.text.set_text(f"x={x}, y={y}")
318322

319323
#blit method (always use because same visual effect as draw)
320324
self.axes.draw_artist(self.axes.patch)

example_cursor_scatter_experimental/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def on_start(self, *args):
4747
mygraph = GraphGenerator()
4848

4949
self.screen.figure_wgt.figure = mygraph.fig
50+
self.screen.figure_wgt.scatter_label = mygraph.ptid
5051
self.screen.figure_wgt.axes = mygraph.ax1
5152
self.screen.figure_wgt.xmin = mygraph.xmin
5253
self.screen.figure_wgt.xmax = mygraph.xmax

0 commit comments

Comments
 (0)