prepare rectangular selection

0.0.9
Theophile Terraz 2024-06-06 14:29:31 +02:00
parent 6c4b67d93a
commit e4f8bc347d
1 changed files with 16 additions and 0 deletions

View File

@ -17,6 +17,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import matplotlib.colors as mplcolors import matplotlib.colors as mplcolors
from matplotlib.widgets import RectangleSelector
from matplotlib import ticker from matplotlib import ticker
from tools import timestamp_to_old_pamhyr_date from tools import timestamp_to_old_pamhyr_date
@ -100,6 +101,14 @@ class PamhyrPlot(APlot):
self._highlight_data_update = False self._highlight_data_update = False
self._current_data = None #: Current data identifier self._current_data = None #: Current data identifier
self._current_data_update = False self._current_data_update = False
self._rect_select = RectangleSelector(ax=self.canvas.axes,
onselect=self.rect_select_callback,
useblit=True,
button=[1, 3], # don't use middle button
minspanx=1.0,
minspany=1.0,
spancoords='pixels',
interactive=False)
@property @property
def canvas(self): def canvas(self):
@ -231,3 +240,10 @@ class PamhyrPlot(APlot):
def onclick(self, event): def onclick(self, event):
return return
def rect_select_callback(self, eclick, erelease):
'eclick and erelease are the press and release events'
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
print("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))
return