I'm all for having more consistent accessors for the various
> object properties. Perhaps something like this would work
> well? (yeah, it's modeled on Tkinter's configure() method)
> # def set(cfgdict=None, **kwds) -> None
> x.set(facecolor='r', size=2)
Well, the current approach is nothing if not consistent. The whole
"set" functionality is based upon the objects having property
setters. Eg, set(PROPERTYNAME=val) always calls
set_PROPERTYNAME(val)
The set function you propose is a good idea and trivial to write.
Just add this function to matplotlib.artist.Artist
def set(self, **kwargs):
"""
A tkstyle set command, pass kwargs to set properties
"""
ret =
for k,v in kwargs.items():
k = k.lower()
funcName = "set_%s"%k
func = getattr(self,funcName)
ret.extend( [func(v)] )
return ret
I'll include this in the next release.
> If anyone else is interested in working to develop a tutorial
> for matplotlib's OO API, please drop me a line... I have a
> vested interest in making matplotlib easier for busy
> developers to use.
I suggest extending Robert's tutorial linked here
http://matplotlib.sourceforge.net/faq.html#OO
Thanks!
JDH