@@ -969,39 +969,27 @@ def set_in_layout(self, in_layout):
969969
970970 def update (self , props ):
971971 """
972- Update this artist's properties from the dictionary *props*.
973- """
974- def _update_property (self , k , v ):
975- """Sorting out how to update property (setter or setattr).
976-
977- Parameters
978- ----------
979- k : str
980- The name of property to update
981- v : obj
982- The value to assign to the property
983-
984- Returns
985- -------
986- ret : obj or None
987- If using a `set_*` method return it's return, else None.
988- """
989- k = k .lower ()
990- # white list attributes we want to be able to update through
991- # art.update, art.set, setp
992- if k in {'axes' }:
993- return setattr (self , k , v )
994- else :
995- func = getattr (self , 'set_' + k , None )
996- if not callable (func ):
997- raise AttributeError ('{!r} object has no property {!r}'
998- .format (type (self ).__name__ , k ))
999- return func (v )
972+ Update this artist's properties from the dict *props*.
1000973
974+ Parameters
975+ ----------
976+ props : dict
977+ """
978+ ret = []
1001979 with cbook ._setattr_cm (self , eventson = False ):
1002- ret = [_update_property (self , k , v ) for k , v in props .items ()]
1003-
1004- if len (ret ):
980+ for k , v in props .items ():
981+ k = k .lower ()
982+ # White list attributes we want to be able to update through
983+ # art.update, art.set, setp.
984+ if k == "axes" :
985+ ret .append (setattr (self , k , v ))
986+ else :
987+ func = getattr (self , f"set_{ k } " , None )
988+ if not callable (func ):
989+ raise AttributeError (f"{ type (self ).__name__ !r} object "
990+ f"has no property { k !r} " )
991+ ret .append (func (v ))
992+ if ret :
1005993 self .pchanged ()
1006994 self .stale = True
1007995 return ret
0 commit comments