@@ -2003,7 +2003,11 @@ def hideCurve(self, legend, flag=True):
2003
2003
_ACTIVE_ITEM_KINDS = "curve" , "scatter" , "image"
2004
2004
"""List of item's kind which have a active item."""
2005
2005
2006
- def remove (self , legend = None , kind = ITEM_KINDS ):
2006
+ def remove (
2007
+ self ,
2008
+ legend : str | items .Item | None = None ,
2009
+ kind : str | Sequence [str ] = ITEM_KINDS ,
2010
+ ):
2007
2011
"""Remove one or all element(s) of the given legend and kind.
2008
2012
2009
2013
Examples:
@@ -2017,13 +2021,16 @@ def remove(self, legend=None, kind=ITEM_KINDS):
2017
2021
- ``remove('myImage')`` removes elements (for instance curve, image,
2018
2022
item and marker) with legend 'myImage'.
2019
2023
2020
- :param str legend: The legend associated to the element to remove,
2021
- or None to remove
2022
- :param kind: The kind of elements to remove from the plot.
2024
+ :param legend:
2025
+ The legend of the item to remove or the item itself.
2026
+ If None all items of given kind are removed.
2027
+ :param kind: The kind of items to remove from the plot.
2023
2028
See :attr:`ITEM_KINDS`.
2024
2029
By default, it removes all kind of elements.
2025
- :type kind: str or tuple of str to specify multiple kinds.
2026
2030
"""
2031
+ if isinstance (legend , items .Item ):
2032
+ return self .removeItem (legend )
2033
+
2027
2034
if kind == "all" : # Replace all by tuple of all kinds
2028
2035
kind = self .ITEM_KINDS
2029
2036
@@ -2050,31 +2057,40 @@ def remove(self, legend=None, kind=ITEM_KINDS):
2050
2057
if item is not None :
2051
2058
self .removeItem (item )
2052
2059
2053
- def removeCurve (self , legend ):
2060
+ def removeCurve (self , legend : str | items . Curve | None ):
2054
2061
"""Remove the curve associated to legend from the graph.
2055
2062
2056
- :param str legend: The legend associated to the curve to be deleted
2063
+ :param legend:
2064
+ The legend of the curve to be deleted or the curve item
2057
2065
"""
2058
2066
if legend is None :
2059
2067
return
2068
+ if isinstance (legend , items .Item ):
2069
+ return self .removeItem (legend )
2060
2070
self .remove (legend , kind = "curve" )
2061
2071
2062
- def removeImage (self , legend ):
2072
+ def removeImage (self , legend : str | items . ImageBase | None ):
2063
2073
"""Remove the image associated to legend from the graph.
2064
2074
2065
- :param str legend: The legend associated to the image to be deleted
2075
+ :param legend:
2076
+ The legend of the image to be deleted or the image item
2066
2077
"""
2067
2078
if legend is None :
2068
2079
return
2080
+ if isinstance (legend , items .Item ):
2081
+ return self .removeItem (legend )
2069
2082
self .remove (legend , kind = "image" )
2070
2083
2071
- def removeMarker (self , legend ):
2084
+ def removeMarker (self , legend : str | items . Marker | None ):
2072
2085
"""Remove the marker associated to legend from the graph.
2073
2086
2074
- :param str legend: The legend associated to the marker to be deleted
2087
+ :param legend:
2088
+ The legend of the marker to be deleted or the marker item
2075
2089
"""
2076
2090
if legend is None :
2077
2091
return
2092
+ if isinstance (legend , items .Item ):
2093
+ return self .removeItem (legend )
2078
2094
self .remove (legend , kind = "marker" )
2079
2095
2080
2096
# Clear
0 commit comments