@@ -17,11 +17,11 @@ class clicker:
17
17
def __init__ (
18
18
self ,
19
19
ax ,
20
- classes = None ,
20
+ classes = 1 ,
21
21
init_class = None ,
22
22
markers = None ,
23
23
colors = None ,
24
- disable_legend = None ,
24
+ disable_legend = False ,
25
25
legend_bbox = (1.04 , 1 ),
26
26
legend_loc = "upper left" ,
27
27
pick_dist = 10 ,
@@ -39,8 +39,8 @@ class in *classes*
39
39
markers : list
40
40
The marker styles to use.
41
41
colors : list
42
- disable_legend : bool
43
- disable to show the classes in the legend, default is False
42
+ disable_legend : bool, default False
43
+ If *True* do not display the legend.
44
44
legend_bbox : tuple
45
45
bbox to use for the legend
46
46
legend_loc : str or int
@@ -51,10 +51,6 @@ class in *classes*
51
51
Line2D objects (from ax.plot) are used to generate the markers.
52
52
line_kwargs will be passed through to all of the `ax.plot` calls.
53
53
"""
54
- if classes is None :
55
- classes = 1
56
- disable_legend = True
57
-
58
54
if isinstance (classes , Integral ):
59
55
self ._classes = list (range (classes ))
60
56
else :
@@ -74,10 +70,6 @@ class in *classes*
74
70
colors = [None ] * len (self ._classes )
75
71
if markers is None :
76
72
markers = ["o" ] * len (self ._classes )
77
- if disable_legend is None :
78
- disable_legend = False
79
- if disable_legend and len (self ._classes ) != 1 :
80
- disable_legend = False
81
73
82
74
self ._disable_legend = disable_legend
83
75
@@ -86,8 +78,6 @@ class in *classes*
86
78
linestyle = line_kwargs .pop ("linestyle" , "" )
87
79
for i , c in enumerate (self ._classes ):
88
80
label = c
89
- if disable_legend :
90
- label = None
91
81
(self ._lines [c ],) = self .ax .plot (
92
82
[],
93
83
[],
@@ -151,22 +141,27 @@ def set_positions(self, positions):
151
141
self ._positions [k ] = list (v )
152
142
self ._observers .process ('pos-set' , self .get_positions ())
153
143
154
- def clear_positions (self , classes = None ):
144
+ def clear_positions (self , classes : str | list [ str ] | None = None ):
155
145
"""
156
- Clears all points of classes in *classes*. Either all classes or a list of classes.
146
+ Clear all points of classes in *classes*.
147
+
148
+ Either all classes or a list of classes.
157
149
158
150
Parameters
159
151
----------
160
- classes : list
161
- A list of classes to clear. If None, all classes will be cleared.
152
+ classes : list, str, optional
153
+ A list, or single, of classes to clear. If None, all classes will be cleared.
162
154
"""
163
155
if classes is None :
164
156
classes = list (self ._positions .keys ())
157
+ elif isinstance (classes , str ):
158
+ classes = [classes ]
165
159
166
160
for k in classes :
167
161
self ._positions [k ].clear ()
168
162
169
163
self ._update_points ()
164
+ self ._observers .process ('pos-set' , self .get_positions ())
170
165
171
166
def _on_pick (self , event ):
172
167
# On the pick event, find the original line corresponding to the legend
0 commit comments