Commit cc9dc5c0 authored by Yori Fournier's avatar Yori Fournier
Browse files

Merge branch 'move-keywords' into 'dev'

new suggestion on MyFig.update().

See merge request !27
parents b49fe698 79b843e8
......@@ -135,23 +135,35 @@ class MyFig(Figure):
elif keyword in self._attributesToUpdateKeys:
# update value
setattr(self, keyword, kwargs[keyword])
# For each axes update the keywords
for ax in self.get_axes():
forax={}
axkwargs = kwargs.copy() # make a copy of kwargs for this axes
for keyword in kwargs.keys():
# ignore figure attributes
if keyword in ['rawdata'] + self._attributesToUpdateKeys :
pass
# Check if a key of kwargs has an alias for this axes
elif keyword in self.aliases.keys():
alax, alkey = self.aliases[keyword]
# Check if a key of kwargs has an alias for this axes
for axk in axkwargs.keys():
if axk in self.aliases.keys():
alax, alkey = self.aliases[axk]
# If an alias is found then update axkwargs
if ax == alax:
axkwargs.update({alkey: kwargs[axk]})
# When eventual alias are added then update
ax.update(**axkwargs)
forax.update(**{alkey: kwargs[keyword]})
# use keyword as it is for the axes
else :
forax.update(**{keyword : kwargs[keyword]})
# Then eventually all collected Keywords are updated in one go
if (forax) :
if self.debug:
print (DBUG+' fig.update ', ax, 'keywords: ', forax)
ax.update(**forax)
return(True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment