Skip to content

Commit 9420b2f

Browse files
Xraydylanianhi
authored andcommitted
Clear positions function
1 parent c767dfa commit 9420b2f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mpl_point_clicker/_clicker.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,23 @@ def set_positions(self, positions):
147147
self._positions[k] = list(v)
148148
self._observers.process('pos-set', self.get_positions())
149149

150+
def clear_positions(self, classes=None):
151+
"""
152+
Clears all points of classes in *classes*. Either all classes or a list of classes.
153+
154+
Parameters
155+
----------
156+
classes : list
157+
A list of classes to clear. If None, all classes will be cleared.
158+
"""
159+
if classes is None:
160+
classes = list(self._positions.keys())
161+
162+
for k in classes:
163+
self._positions[k].clear()
164+
165+
self._update_points()
166+
150167
def _on_pick(self, event):
151168
# On the pick event, find the original line corresponding to the legend
152169
# proxy line, and toggle its visibility.

0 commit comments

Comments
 (0)