@@ -17,11 +17,11 @@ class clicker:
1717 def __init__ (
1818 self ,
1919 ax ,
20- classes = None ,
20+ classes = 1 ,
2121 init_class = None ,
2222 markers = None ,
2323 colors = None ,
24- disable_legend = None ,
24+ disable_legend = False ,
2525 legend_bbox = (1.04 , 1 ),
2626 legend_loc = "upper left" ,
2727 pick_dist = 10 ,
@@ -39,8 +39,8 @@ class in *classes*
3939 markers : list
4040 The marker styles to use.
4141 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.
4444 legend_bbox : tuple
4545 bbox to use for the legend
4646 legend_loc : str or int
@@ -51,10 +51,6 @@ class in *classes*
5151 Line2D objects (from ax.plot) are used to generate the markers.
5252 line_kwargs will be passed through to all of the `ax.plot` calls.
5353 """
54- if classes is None :
55- classes = 1
56- disable_legend = True
57-
5854 if isinstance (classes , Integral ):
5955 self ._classes = list (range (classes ))
6056 else :
@@ -74,10 +70,6 @@ class in *classes*
7470 colors = [None ] * len (self ._classes )
7571 if markers is None :
7672 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
8173
8274 self ._disable_legend = disable_legend
8375
@@ -86,8 +78,6 @@ class in *classes*
8678 linestyle = line_kwargs .pop ("linestyle" , "" )
8779 for i , c in enumerate (self ._classes ):
8880 label = c
89- if disable_legend :
90- label = None
9181 (self ._lines [c ],) = self .ax .plot (
9282 [],
9383 [],
@@ -151,22 +141,27 @@ def set_positions(self, positions):
151141 self ._positions [k ] = list (v )
152142 self ._observers .process ('pos-set' , self .get_positions ())
153143
154- def clear_positions (self , classes = None ):
144+ def clear_positions (self , classes : str | list [ str ] | None = None ):
155145 """
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.
157149
158150 Parameters
159151 ----------
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.
162154 """
163155 if classes is None :
164156 classes = list (self ._positions .keys ())
157+ elif isinstance (classes , str ):
158+ classes = [classes ]
165159
166160 for k in classes :
167161 self ._positions [k ].clear ()
168162
169163 self ._update_points ()
164+ self ._observers .process ('pos-set' , self .get_positions ())
170165
171166 def _on_pick (self , event ):
172167 # On the pick event, find the original line corresponding to the legend
0 commit comments